Background: Longitudinal data on the population prevalence of HIV drug resistance during scale-up of HIV treatment in Africa are extremely limited. We estimated trends in HIV drug resistance prevalence during ART program expansion from a population-based surveillance cohort in southern Uganda. Methods: We analyzed data from Rakai Community Cohort Study participants aged 15-49 during four survey rounds conducted between 2012 (round 15) and 2019 (round 19). Consenting participants were tested for HIV and completed questionnaires. Persons living with HIV (PLHIV) provided samples for viral load quantification and virus deep-sequencing. Sequence data were used to predict resistance profiles. The prevalence of class-specific resistance and resistance-conferring substitutions were estimated using robust log-Poisson regression. Findings: 93,659 participant visits were contributed between 2012 and 2019, including 17,471 (18.65%) from PLHIV. Using deep-sequencing data from 3,713 pre-treatment participant-visits we estimated that the population prevalence of viremic NNRTI, NRTI, and PI resistance decreased significantly between 2012 and 2017 (PR = 0.38, 95% CI 0.25 - 0.57; 0.20, 95% CI 0.09 - 0.45; 0.19, 95% CI 0.09 - 0.39, respectively) with increasing viral suppression. Among viremic pre- treatment PLHIV, the prevalence of NNRTI resistance increased two-fold (PR = 1.96, 95% CI 1.31-2.95) to 9.77% (7.35% - 12.97%) over the same time period. We did not observe an increase in NRTI or PI resistance in this population. The 2017 prevalence of NNRTI and NRTI resistance among viremic treatment-experienced PLHIV was 47.67% (95% CI 40.94% - 55.50%) and 36.55% (95% CI 30.14% - 44.31%), respectively. Single-class resistance predominated among resistant pre-treatment PLHIV (83.05%) whereas most treatment-experienced resistance was multi-class (76.65%). In 2017, 10.13% (95% CI 7.83%-13.63%) and 9.98% (95% CI 6.43%- 15.51%) of viremic pre-treatment and treatment-experienced PLHIV harbored the inT97A mutation. Interpretation: Prevalence of HIV drug resistance among viremic PLHIV significantly increased with scale-up of ART programs. The prevalence of inT97A is potentially concerning considering the recent roll-out of dolutegravir-based regimens. Funding: National Institutes of Health, the Bill & Melinda Gates Foundation, and the U.S. President's Emergence Plan for AIDS Relief through the Centers for Disease Control and Prevention.