Summary Background Nevirapine given once-daily for the first 6, 14, or 28 weeks of life to infants exposed to HIV-1 via breastfeeding reduces transmission through this route compared with single-dose nevirapine at birth or neonatally. We aimed to assess incremental safety and efficacy of extension of such prophylaxis to 6 months. Methods In our phase 3, randomised, double-blind, placebo-controlled HPTN 046 trial, we assessed the incremental benefit of extension of once-daily infant nevirapine from age 6 weeks to 6 months. We enrolled breastfeeding infants born to mothers with HIV-1 in four African countries within 7 days of birth. Following receipt of nevirapine from birth to 6 weeks, infants without HIV infection were randomly allocated (by use of a computer-generated permuted block algorithm with random block sizes and stratified by site and maternal antiretroviral treatment status) to receive extended nevirapine prophylaxis or placebo until 6 months or until breastfeeding cessation, whichever came first. The primary efficacy endpoint was HIV-1 infection in infants at 6 months and safety endpoints were adverse reactions in both groups. We used Kaplan-Meier analyses to compare differences in the primary outcome between groups. This study is registered with ClinicalTrials.gov, number NCT00074412. Findings Between June 19, 2008, and March 12, 2010, we randomly allocated 1527 infants (762 nevirapine and 765 placebo); five of whom had HIV-1 infection at randomisation and were excluded from the primary analyses. In Kaplan-Meier analysis, 1·1% (95% CI 0·3–1·8) of infants who received extended nevirapine developed HIV-1 between 6 weeks and 6 months compared with 2·4% (1·3–3·6) of controls (difference 1·3%, 95% CI 0–2·6), equating to a 54% reduction in transmission (p=0·049). However, mortality (1·2% for nevirapine vs 1·1% for placebo; p=0·81) and combined HIV infection and mortality rates (2·3% vs 3·2%; p=0·27) did not differ between groups at 6 months. 125 (16%) of 758 infants given extended nevirapine and 116 (15%) of 761 controls had serious adverse events, but frequency of adverse events, serious adverse events, and deaths did not differ significantly between treatment groups. Interpretation Nevirapine prophylaxis can safely be used to provide protection from mother-to-child transmission of HIV-1 via breastfeeding for infants up to 6 months of age. Funding US National Institutes of Health.