IntroductionThere are no longitudinal HIV incidence data among men who have sex with men (MSM) and transgender women (TGW) in Indonesia. We aimed to estimate HIV prevalence and incidence and identify associated factors among clinic attendees in Jakarta and Bali.MethodsWe conducted a retrospective cohort study using medical records from five clinics. We reviewed HIV tests among MSM/TGW aged ≥18 years who attended the clinics between 1 January 2018 to 31 December 2020 in Jakarta and 1 January 2017 to 31 December 2019 in Bali. HIV prevalence was measured at the first test. Those with an HIV‐negative test and ≥1 follow‐up test/s were included in the person‐years (PY) at risk to determine HIV incidence. The PY at risk calculation started at the first negative test until the last recorded negative test or seroconversion. Multivariate Poisson regression was used to determine factors associated with HIV acquisition.ResultsAmong 5203 and 2815 individuals with an HIV test result in Jakarta and Bali, respectively, at the first HIV test, 1205 and 616 were HIV positive (HIV prevalence 23.2% and 21.9%). The longitudinal sample included 1418 and 873 individuals, respectively. The median number of tests among repeat testers was 3 in Jakarta (interquartile range [IQR] = 2–4) and 3 in Bali (IQR = 2–5). At baseline, about one‐quarter were aged <25 years, >90% were MSM and >35% had been tested for HIV previously. In Jakarta, there were 127 HIV seroconversions in 1353 PY (incidence 9.39/100 PY, 95% CI = 7.89–11.17), and in Bali, 71 seroconversions in 982 PY (incidence 7.24/100 PY, 95% CI = 5.73–9.13). Compared to those aged 18–24 years, the incidence rate was lower in older patients (Jakarta—30–39 years: aRR = 0.56, 95% CI = 0.34–0.92; 40+ years: aRR = 0.34, 95% CI = 0.14–0.81; Bali—25–29 years: aRR = 0.44, 95% CI = 0.25–0.79; 30–39 years: aRR = 0.33, 95% CI = 0.18–0.61; 40+ years: aRR = 0.06, 95% CI = 0.01–0.48). In Jakarta, incidence was lower in those with university education than in those without (aRR = 0.66, 95% CI = 0.45–0.96). In Bali, those who had been referred by outreach workers had a higher incidence than those who self‐presented for testing (aRR = 1.85, 95% CI = 1.12–3.07).ConclusionsWe observed very high HIV prevalence and incidence rate estimates. Measures to encourage regular testing and effective use of HIV prevention, including pre‐exposure prophylaxis scale‐up and demand creation, are needed.