IntroductionPregnant women living with HIV can achieve viral suppression and prevent HIV mother‐to‐child transmission (MTCT) with timely HIV testing and early ART initiation and maintenance. Although it is recommended that pregnant women undergo HIV testing early in antenatal care in Malawi, many women test positive during breastfeeding because they did not have their HIV status ascertained during pregnancy, or they tested negative during pregnancy but seroconverted postpartum. We sought to estimate the association between the timing of last positive HIV test (during pregnancy vs. breastfeeding) and outcomes of maternal viral suppression and MTCT in Malawi’s PMTCT programme.MethodsWe conducted a two‐stage cohort study among mother–infant pairs in 30 randomly selected high‐volume health facilities across five nationally representative districts of Malawi between 1 July 2016 and 30 June 2017. Log‐binomial regression was used to estimate prevalence ratios (PR) and risk ratios (RR) for associations between timing of last positive HIV test (i.e. breastfeeding vs. pregnancy) and maternal viral suppression and MTCT, controlling for confounding using inverse probability weighting.ResultsOf 822 mother–infant pairs who had available information on the timing of the last positive HIV test, 102 mothers (12.4%) had their last positive test during breastfeeding. Women who lived one to two hours (PR = 2.15; 95% CI: 1.29 to 3.58) or >2 hours (PR = 2.36; 95% CI: 1.37 to 4.10) travel time to the nearest health facility were more likely to have had their last positive HIV test during breastfeeding compared to women living <1 hour travel time to the nearest health facility. The risk of unsuppressed VL did not differ between women who had their last positive HIV test during breastfeeding versus pregnancy (adjusted RR [aRR] = 0.87; 95% CI: 0.48 to 1.57). MTCT risk was higher among women who had their last positive HIV test during breastfeeding compared to women who had it during pregnancy (aRR = 6.57; 95% CI: 3.37 to 12.81).ConclusionsMTCT in Malawi occurred disproportionately among women with a last positive HIV test during breastfeeding. Testing delayed until the postpartum period may lead to higher MTCT. To optimize maternal and child health outcomes, PMTCT programmes should focus on early ART initiation and providing targeted testing, prevention, treatment and support to breastfeeding women.