Objective: To assess the relationship between infant feeding practices and mortality by 18 months of age among children born to HIV-infected mothers in the Kesho Bora trial (Burkina-Faso, Kenya and South Africa). Methods: Enrolled HIV-infected women were counseled to choose between breastfeeding up to 6 months or replacement feeding from delivery. Multivariable Cox models were used to compare the infant mortality risks according to feeding practices over time defined as never breastfed, weaned or still breastfed. The category 'still breastfed' was disaggregated as exclusively, predominantly or partially breastfed to compare modes of breastfeeding. The relationship between weaning and mortality was also assessed using marginal structural models to control for time-dependent confounders, such as maternal or infant morbidity (reverse causality). Results: Among 795 mothers, 618 (77.7%) initiated breastfeeding. Mortality rates by 18 months among uninfected and infected children were 6 and 38%, respectively. Never breastfed and weaned children were at greater risk of death compared with those still breastfed. Adjusted hazard ratios were 6.7 [95% confidence interval (CI)=2.5-17.9; P< 0.001] and 6.9 (CI = 2.8-17.2; P< 0.001) for never breastfed and weaned children, respectively. Estimation of the effect of weaning using marginal structural models led to similar results. No statistically significant differences were observed according to mode of breastfeeding (exclusive, predominant or partial). Conclusion: Within 6 months after birth, weaned or never breastfed children were at about seven-fold higher risk of dying compared with children who were still breastfed despite a context in which interventions were provided to reduce risks associated with replacement feeding.