Clinical studies have reported rising pre-treatment HIV drug resistance during antiretroviral treatment (ART) scale-up in Africa, but representative data are limited. We estimated population-level drug resistance trends during ART expansion in Uganda. We analyzed data from the population-based open Rakai Community Cohort Study conducted at agrarian, trading, and fishing communities in southern Uganda between 2012 and 2019. Consenting participants aged 15-49 were HIV tested 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. Population prevalence of class-specific resistance and resistance-conferring substitutions were estimated using robust log-Poisson regression. Data from 93,622 participant-visits, including 4,702 deep-sequencing measurements, showed that the prevalence of NNRTI resistance among pre-treatment viremic PLHIV doubled between 2012 and 2017 (PR:1.98, 95%CI:1.34-2.91), rising to 9.61% (7.27-12.7%). The overall population prevalence of pre-treatment viremic NNRTI and NRTI resistance among all participants decreased during the same period, reaching 0.25% (0.18% - 0.33%) and 0.05% (0.02% - 0.10%), respectively ( p- values for trend = 0.00015, 0.002), coincident with increasing treatment coverage and viral suppression. By the final survey, population prevalence of resistance contributed by treatment-experienced PLHIV exceeded that from pre-treatment PLHIV, with NNRTI resistance at 0.54% (0.44%-0.66%) and NRTI resistance at 0.42% (0.33% - 0.53%). Overall, NNRTI and NRTI resistance was predominantly attributable to rtK103N and rtM184V. While 10.52% (7.97%-13.87%) and 9.95% (6.41%-15.43%) of viremic pre-treatment and treatment-experienced PLHIV harbored the inT97A mutation, no major dolutegravir resistance mutations were observed. Despite rising NNRTI resistance among pre-treatment PLHIV, overall population prevalence of pre-treatment resistance decreased due to treatment uptake. Most NNRTI and NRTI resistance is now contributed by treatment-experienced PLHIV. The high prevalence of mutations conferring resistance to components of current first-line ART regimens among PLHIV with viremia is potentially concerning. National Institutes of Health and the Gates Foundation. Evidence before the study: We searched PubMed for studies matching the keywords "hiv" "resistance" "longitudinal" "cohort" "population" published since 2004 (the beginning of antiretroviral therapy (ART) availability in sub-Saharan Africa) and identified 50 studies. We excluded 34 studies not based in sub-Saharan Africa, five studies primarily concerned with infection with other pathogens (e.g. HBV, M. tuberculosis ), two studies concerned with insulin resistance, one sequencing-methods paper, and one paper concerned with host susceptibility to HIV infection. The remaining seven studies were not population-based meaning that the study population was not all persons but e.g. people living with HIV enrolled in care at a given clinic. Population-based cohort are essential for monitoring HIV drug resistance in both treated and untreated individuals, including those people who may go undetected in clinical settings, capturing evolutionary dynamics of resistance in real-world conditions. Added value of this study: We estimated the prevalence of drug resistance over five consecutive survey rounds of a population-based open-cohort study in southern Uganda between 2012 and 2019 during a period of intense treatment scale-up. We show that among the entire population regardless of HIV status, 0.8% and 0.5% of individuals harbor viremic resistance to non-nucleoside reverse transcriptase inhibitors (NNRTIs) and nucleoside-reverse transcriptase inhibitors (NRTIs), respectively, of which the majority is dual-class NNRTI/NRTI resistance. Despite a two-fold increase in the prevalence of NNRTI resistance among pre-treatment viremic PLHIV, the overall prevalence of pre-treatment viremic resistance in the entire population decreased by more than 50% due to increased treatment initiation and population viral load suppression. The majority of resistance in recent survey rounds was contributed by treatment-experienced PLHIV. Among treatment-experienced viremic PLHIV, we observe a substantial burden of mutations that confer resistance to the NNRTI and NRTI components of dolutegravir and cabotegravir based regimens e.g. rtM184V (34%) rtY181C (15%), rtG190A (12%), rtK65R (12%), and rtK101E (9.5%). The integrase strand transfer inhibitor (INSTI) resistance mutation inT97A was observed in about a tenth of viremic PLHIV.These results provide the first longitudinal population-based estimates of temporal trends in the prevalence of drug resistance during ART program expansion in a high-burden setting. Further, they provide critical insight into the landscape of prevalent drug resistance substitutions circulating in this population.Implications of all the available evidence: Scale-up of HIV treatment has increased the prevalence of drug resistance mutations among viremic people living with HIV in sub-Saharan Africa. The relatively high prevalence of NNRTI resistance has prompted a recent shift to first-line regimens including dolutegravir (an INSTI) in combination with NRTIs. The high prevalence of mutations conferring resistance to components of current first-line regimens in our population warrants continued monitoring of treatment failures and the prevalence of drug resistance in high burden settings.