The cornerstone of malaria prevention in pregnancy, intermittent preventive treatment (IPTp) with sulfadoxine-pyrimethamine, is contraindicated in women with HIV who are receiving co-trimoxazole prophylaxis. We assessed whether IPTp with dihydroartemisinin-piperaquine is safe and effective in reducing the risk of malaria infection in women with HIV receiving co-trimoxazole prophylaxis and antiretroviral drugs. For this randomised, double-blind, placebo-controlled clinical trial, women with HIV attending the first antenatal care clinic visit, resident in the study area, and with a gestational age up to 28 weeks were enrolled at five sites in Gabon and Mozambique. Participants were randomly assigned (1:1) to receive either IPTp with dihydroartemisinin-piperaquine at each scheduled antenatal care visit plus daily co-trimoxazole (intervention group) or placebo at each scheduled antenatal care visit plus daily co-trimoxazole (control group). Randomisation was done centrally via block randomisation (block sizes of eight), stratified by country. IPTp was given over 3 days under direct observation by masked study personnel. The number of daily IPTp tablets was based on bodyweight and according to the treatment guidelines set by WHO (target dose of 4 mg/kg per day [range 2-10 mg/kg per day] of dihydroartemisinin and 18 mg/kg per day [range 16-27 mg/kg per day] of piperaquine given once a day for 3 days). At enrolment, all participants received co-trimoxazole (fixed combination drug containing 800 mg trimethoprim and 160 mg sulfamethoxazole) for daily intake. The primary study outcome was prevalence of peripheral parasitaemia detected by microscopy at delivery. The modified intention-to-treat population included all randomly assigned women who had data for the primary outcome. Secondary outcomes included frequency of adverse events, incidence of clinical malaria during pregnancy, and frequency of poor pregnancy outcomes. All study personnel, investigators, outcome assessors, data analysts, and participants were masked to treatment assignment. This study is registered with ClinicalTrials.gov, NCT03671109. From Sept 18, 2019, to Nov 26, 2021, 666 women (mean age 28·5 years [SD 6·4]) were enrolled and randomly assigned to the intervention (n=332) and control (n=334) groups. 294 women in the intervention group and 308 women in the control group had peripheral blood samples taken at delivery and were included in the primary analysis. Peripheral parasitaemia at delivery was detected in one (<1%) of 294 women in the intervention group and none of 308 women in the control group. The incidence of clinical malaria during pregnancy was lower in the intervention group than in the control group (one episode in the intervention group vs six in the control group; relative risk [RR] 0·12, 95% CI 0·03-0·52, p=0·045). In a post-hoc analysis, the composite outcome of overall malaria infection (detected by any diagnostic test during pregnancy or delivery) was lower in the intervention group than in the control group (14 [5%] of 311 women vs 31 [10%] of 320 women; RR 0·48, 95% CI 0·27-0·84, p=0·010). The frequency of serious adverse events and poor pregnancy outcomes (such as miscarriages, stillbirths, premature births, and congenital malformations) did not differ between groups. The most frequently reported drug-related adverse events were gastrointestinal disorder (reported in less than 4% of participants) and headache (reported in less than 2% of participants), with no differences between study groups. In the context of low malaria transmission, the addition of IPTp with dihydroartemisinin-piperaquine to co-trimoxazole prophylaxis in pregnant women with HIV did not reduce peripheral parasitaemia at delivery. However, the intervention was safe and associated with a decreased risk of clinical malaria and overall Plasmodium falciparum infection, so it should be considered as a strategy to protect pregnant women with HIV from malaria. European and Developing Countries Clinical Trials Partnership 2 (EDCTP2) and Medicines for Malaria Venture. For the Portuguese and French translations of the abstract see Supplementary Materials section.