BACKGROUND In resource-limited settings where no safe alternative to breastfeeding exists, WHO recommends that antiretroviral prophylaxis be given to either HIV-infected mothers or infants throughout breastfeeding. We assessed the effect of 28 weeks of maternal or infant antiretroviral prophylaxis on postnatal HIV infection at 48 weeks. METHODS The Breastfeeding, Antiretrovirals, and Nutrition (BAN) Study was undertaken in Lilongwe, Malawi, between April 21, 2004, and Jan 28, 2010. 2369 HIV-infected breastfeeding mothers with a CD4 count of 250 cells per μL or more and their newborn babies were randomly assigned with a variable-block design to one of three, 28-week regimens: maternal triple antiretroviral (n=849); daily infant nevirapine (n=852); or control (n=668). Patients and local clinical staff were not masked to treatment allocation, but other study investigators were. All mothers and infants received one dose of nevirapine (mother 200 mg; infant 2 mg/kg) and 7 days of zidovudine (mother 300 mg; infants 2 mg/kg) and lamivudine (mothers 150 mg; infants 4 mg/kg) twice a day. Mothers were advised to wean between 24 weeks and 28 weeks after birth. The primary endpoint was HIV infection by 48 weeks in infants who were not infected at 2 weeks and in all infants randomly assigned with censoring at loss to follow-up. This trial is registered with ClinicalTrials.gov, number NCT00164736. FINDINGS 676 mother-infant pairs completed follow-up to 48 weeks or reached an endpoint in the maternal-antiretroviral group, 680 in the infant-nevirapine group, and 542 in the control group. By 32 weeks post partum, 96% of women in the intervention groups and 88% of those in the control group reported no breastfeeding since their 28-week visit. 30 infants in the maternal-antiretroviral group, 25 in the infant-nevirapine group, and 38 in the control group became HIV infected between 2 weeks and 48 weeks of life; 28 (30%) infections occurred after 28 weeks (nine in maternal-antiretroviral, 13 in infant-nevirapine, and six in control groups). The cumulative risk of HIV-1 transmission by 48 weeks was significantly higher in the control group (7%, 95% CI 5-9) than in the maternal-antiretroviral (4%, 3-6; p=0·0273) or the infant-nevirapine (4%, 2-5; p=0·0027) groups. The rate of serious adverse events in infants was significantly higher during 29-48 weeks than during the intervention phase (1·1 [95% CI 1·0-1·2] vs 0·7 [0·7-0·8] per 100 person-weeks; p<0·0001), with increased risk of diarrhoea, malaria, growth faltering, tuberculosis, and death. Nine women died between 2 weeks and 48 weeks post partum (one in maternal-antiretroviral group, two in infant-nevirapine group, six in control group). INTERPRETATION In resource-limited settings where no suitable alternative to breastfeeding is available, antiretroviral prophylaxis given to mothers or infants might decrease HIV transmission. Weaning at 6 months might increase infant morbidity. FUNDING US Centers for Disease Control and Prevention.