ImportanceSARS-CoV-2 infection may lead to acute and chronic sequelae. Emerging evidence suggests a higher risk of diabetes after infection, but population-based evidence is still sparse.ObjectiveTo evaluate the association between COVID-19 infection, including severity of infection, and risk of diabetes.Design, Setting, and ParticipantsThis population-based cohort study was conducted in British Columbia, Canada, from January 1, 2020, to December 31, 2021, using the British Columbia COVID-19 Cohort, a surveillance platform that integrates COVID-19 data with population-based registries and administrative data sets. Individuals tested for SARS-CoV-2 by real-time reverse transcription-polymerase chain reaction (RT-PCR) were included. Those who tested positive for SARS-CoV-2 (ie, those who were exposed) were matched on sex, age, and collection date of RT-PCR test at a 1:4 ratio to those who tested negative (ie, those who were unexposed). Analysis was conducted January 14, 2022, to January 19, 2023.ExposureSARS-CoV-2 infection.Main Outcomes and MeasuresThe primary outcome was incident diabetes (insulin dependent or not insulin dependent) identified more than 30 days after the specimen collection date for the SARS-CoV-2 test with a validated algorithm based on medical visits, hospitalization records, chronic disease registry, and prescription drugs for diabetes management. Multivariable Cox proportional hazard modeling was performed to evaluate the association between SARS-CoV-2 infection and diabetes risk. Stratified analyses were performed to assess the interaction of SARS-CoV-2 infection with diabetes risk by sex, age, and vaccination status.ResultsAmong 629 935 individuals (median [IQR] age, 32 [25.0-42.0] years; 322 565 females [51.2%]) tested for SARS-CoV-2 in the analytic sample, 125 987 individuals were exposed and 503 948 individuals were unexposed. During the median (IQR) follow-up of 257 (102-356) days, events of incident diabetes were observed among 608 individuals who were exposed (0.5%) and 1864 individuals who were not exposed (0.4%). The incident diabetes rate per 100 000 person-years was significantly higher in the exposed vs nonexposed group (672.2 incidents; 95% CI, 618.7-725.6 incidents vs 508.7 incidents; 95% CI, 485.6-531.8 incidents; P < .001). The risk of incident diabetes was also higher in the exposed group (hazard ratio [HR], 1.17; 95% CI, 1.06-1.28) and among males (adjusted HR, 1.22; 95% CI, 1.06-1.40). The risk of diabetes was higher among people with severe disease vs those without COVID-19, including individuals admitted to the intensive care unit (HR, 3.29; 95% CI, 1.98-5.48) or hospital (HR, 2.42; 95% CI, 1.87-3.15). The fraction of incident diabetes cases attributable to SARS-CoV-2 infection was 3.41% (95% CI, 1.20%-5.61%) overall and 4.75% (95% CI, 1.30%-8.20%) among males.Conclusions and RelevanceIn this cohort study, SARS-CoV-2 infection was associated with a higher risk of diabetes and may have contributed to a 3% to 5% excess burden of diabetes at a population level.