Background Understanding the patterns of HIV/AIDS epidemics is crucial to tracking and monitoring the progress of prevention and control efforts in countries. We provide a comprehensive assessment of the levels and trends of HIV/AIDS incidence, prevalence, mortality, and coverage of antiretroviral therapy (ART) for 1980-2017 and forecast these estimates to 2030 for 195 countries and territories. Methods We determined a modelling strategy for each country on the basis of the availability and quality of data. For countries and territories with data from population-based seroprevalence surveys or antenatal care clinics, we estimated prevalence and incidence using an open-source version of the Estimation and Projection Package - a natural history model originally developed by the UNAIDS Reference Group on Estimates, Modelling, and Projections. For countries with cause-specific vital registration data, we corrected data for garbage coding (ie, deaths coded to an intermediate, immediate, or poorly defined cause) and HIV misclassification. We developed a process of cohort incidence bias adjustment to use information on survival and deaths recorded in vital registration to back-calculate HIV incidence. For countries without any representative data on HIV, we produced incidence estimates by pulling information from observed bias in the geographical region. We used a re-coded version of the Spectrum model (a cohort component model that uses rates of disease progression and HIV mortality on and off ART) to produce agesex- specific incidence, prevalence, and mortality, and treatment coverage results for all countries, and forecast these measures to 2030 using Spectrum with inputs that were extended on the basis of past trends in treatment scale-up and new infections. Findings Global HIV mortality peaked in 2006 with 1·95 million deaths (95% uncertainty interval 1·87-2·04) and has since decreased to 0·95 million deaths (0·91-1·01) in 2017. New cases of HIV globally peaked in 1999 (3·16 million, 2·79-3·67) and since then have gradually decreased to 1·94 million (1·63-2·29) in 2017. These trends, along with ART scale-up, have globally resulted in increased prevalence, with 36·8 million (34·8-39·2) people living with HIV in 2017. Prevalence of HIV was highest in southern sub-Saharan Africa in 2017, and countries in the region had ART coverage ranging from 65·7% in Lesotho to 85·7% in eSwatini. Our forecasts showed that 54 countries will meet the UNAIDS target of 81% ART coverage by 2020 and 12 countries are on track to meet 90% ART coverage by 2030. Forecasted results estimate that few countries will meet the UNAIDS 2020 and 2030 mortality and incidence targets. Interpretation Despite progress in reducing HIV-related mortality over the past decade, slow decreases in incidence, combined with the current context of stagnated funding for related interventions, mean that many countries are not on track to reach the 2020 and 2030 global targets for reduction in incidence and mortality. With a growing population of people living with HIV, it will continue to be a major threat to public health for years to come. The pace of progress needs to be hastened by continuing to expand access to ART and increasing investments in proven HIV prevention initiatives that can be scaled up to have population-level impact.