Background: Young women in southern Africa have substantial risk of HIV acquisition. Female-controlled biomedical interventions are needed to mitigate this risk. We aimed to assess the safety and efficacy of a pericoitally applied tenofovir 1% gel. Methods: We did a phase 3, double-blind, randomised, placebo-controlled trial at nine community-based clinical trial sites in South Africa to evaluate the safety and efficacy of tenofovir 1% gel. Sexually active women who were HIV negative and aged 18–30 years were enrolled. Participants were randomly assigned (1:1) using sequential participant numbers to either tenofovir 1% gel or a placebo gel (one dose within 12 h before sex and one dose within 12 h after sex [BAT-24 regimen]), using dynamic permuted block sizes of 8 and 16 within each site. Women received monthly HIV-1 testing, risk reduction support, physical examinations, and product dispensing for up to 27 months. The primary efficacy outcome was incident HIV infection and the primary safety outcome was occurrence of grade 2–4 adverse events, both analysed in the modified intention-to-treat population. To assess the efficacy of tenofovir gel, the cumulative probability of HIV infection was calculated for each treatment using the Kaplan-Meier method. This trial is registered with ClinicalTrials.gov, number NCT01386294. Findings: From Oct 11, 2011, to Aug 29, 2014, 3844 women were screened, 2059 enrolled, and 2029 included in the primary analysis (1032 in the tenofovir group and 1027 in the placebo group); 39 (4%) in the tenofovir group and 36 (4%) in the placebo group were lost to follow-up. 123 HIV-1 infections occurred over 3036 woman-years of observation; 61 in the tenofovir group (HIV incidence 4·0 per 100 woman-years, 95% CI 3·1–5·2) and 62 in the placebo group (4·0 per 100 woman-years, 3·1–5·2; incidence rate ratio [IRR] 0·98, 95% CI 0·7–1·4). A higher incidence of grade 2 adverse events was observed in the tenofovir group than in the placebo group (IRR 1·09, 95% CI 1·0–1·2; p=0·02). The most common grade 2 or higher product-related adverse events were hypophosphataemia (n=22 for tenofovir vs n=22 for placebo), genital symptoms (n=6 for tenofovir vs n=2 for placebo), or elevated transaminases (n=2 for tenofovir vs n=2 for placebo). No product-related serious adverse events were reported, and no differences in product-related adverse events (p=0·78), grade 3 events (p=0·64), or grade 4 events (p=0·74) were observed between treatment groups. Interpretation: Overall, pericoital tenofovir gel did not prevent HIV-1 acquisition in this population of young women at risk of HIV infection in South Africa. Alternate safe and effective products that are less user dependent than this product or do not require high adherence are needed. Funding: The US Agency for International Development (USAID), the Bill & Melinda Gates Foundation, and the South African Department of Science and Technology and Department of Health.