Objectives To investigate risk factors associated with death of infants with a congenital anomaly in Wales, UK.Design A population-based cohort study.Setting Data from the Welsh Congenital Anomaly Register and Information Service (CARIS) linked to live births and deaths from the Office for National Statistics.Patients All live births between 1998 and 2016 with a diagnosis of a congenital anomaly, which was defined as a structural, metabolic, endocrine or genetic defect, as well as rare disease of hereditary origin.Main outcome measures Adjusted ORs (aORs) were estimated for socio-demographic, maternal, infant and intervention factors associated with death in infancy, using logistic regression for all, isolated, multiple and cardiovascular anomalies.Results 30 424 live births affected by congenital anomalies were identified, including 1044 infants who died by the age of 1 year (infant mortality rate: 16.5 per 10 000 live births, case fatality: 3.4%, 30.3% of all infant deaths). Risk factors for infant death were non-white versus white ethnicity (aOR: 2.25; 95% CI: 1.77–2.86); parous versus nulliparous (aOR: 1.24; 95% CI: 1.08–1.41); smoking during pregnancy versus non-smokers/ex-smokers (aOR: 1.20; 95% CI: 1.02–1.40); preterm versus term birth (aOR: 4.38; 95% CI 3.86–4.98); female versus male infants (aOR: 1.28; 95% CI: 1.13–1.46) and the earlier years of the birth cohort (aOR: 0.96; 95% CI: 0.95–0.98 per yearly increase). Infants with a cardiovascular anomaly who received surgery had a lower odds of death than those who did not (aOR: 0.34; 95% CI: 0.15–0.75). Preterm birth was a significant factor for death for all anomalies but the effect of the other characteristics varied according to anomaly group.Conclusions Nearly a third of all infant deaths had an associated anomaly. Improving access to prenatal care, smoking cessation advice, optimising care for preterm infants and surgery may help lower the risk of infant death.