To prevent vertical HIV transmission and ensure healthy mothers and children, pregnant women with HIV must remain on antiretroviral treatment (ART) for life. However, motivation to remain on ART may decline beyond the standard 2-year breastfeeding/postpartum period. We assessed attrition and retention in ART care among women with HIV up to 6 years since enrolment in vertical transmission prevention services in Dar es Salaam, Tanzania. A prospective cohort of 22,631 pregnant women with HIV were enrolled in vertical transmission prevention services between January 2015 and December 2017 in routine healthcare settings and followed-up to July 2021. Kaplan-Meier was used to estimate time to ART attrition (died, stopped ART or was lost to follow-up [no show ≥90 days since scheduled appointment]) and the proportion retained in care. Cox proportional hazard models were used to estimate adjusted hazard ratios (aHR) of ART attrition in relation to predictors. Participants were followed-up to 6 years for a median of 3 years (IQR: 0.1-4). The overall ART attrition rate was 13.8 per 100 person-years (95% CI: 13.5-14.1), highest in the first year of enrolment at 27.1 (26.3-27.9), thereafter declined to 9.5 (8.9-10.1) in year 3 and 2.7 (2.1-3.5) in year 6. The proportion of women retained in care were 78%, 69%, 63%, 60%, 57% and 56% at 1, 2, 3, 4, 5 and 6 years, respectively. ART attrition was higher in young women aged <20 years (aHR 1.63, 95% CI: 1.38-1.92) as compared to 30-39 year-olds and women enrolled late in the third versus first trimester (aHR 1.29, 95% CI: 1.16-1.44). In contrast, attrition was lower in older women ≥40 years, women who initiated ART before versus during the index pregnancy and women attending higher-level health facilities. ART attrition among women with HIV remains highest in the first year of enrolment in vertical transmission prevention services and declines markedly following a transition to chronic HIV care. Targeted interventions to improve ART continuity among women with HIV during and beyond prevention of vertical transmission are vital to ending paediatric HIV and keeping women and children alive and healthy.