Early identification of people who use opioids in pregnancy may improve health outcomes for pregnant people and infants. However, characterization of diverse circumstances surrounding type of opioid use and indications for opioid use are lacking. To develop clinically distinct groups of people who use opioids in pregnancy and to evaluate their association with drug overdose or death up to 1 year post partum. This is a population-based, repeated cross-sectional study conducted in Ontario, Canada, with participants who used opioids in pregnancy who had a live birth or stillbirth between January 1, 2014, and December 31, 2019, identified in health administrative databases. Data were analyzed from August 2020 to January 2021. Prenatal opioid use. Latent class analysis (LCA), based on prenatal opioid use and 19 socioeconomic and medical characteristics, first identified clinically distinct groups of opioid users. Then, within the optimally derived LCA-derived group, adjusted relative risks (aRRs) were generated for the outcome of drug overdose or all-cause death within 1 year post partum, adjusting for birthing parent age and year of delivery. The analysis included 31 241 people with prenatal opioid use (mean [SD] age, 30.0 [5.6] years; 86.1% [26 908 individuals] Canadian-born; 30.6% [9574 individuals] lived in low-income neighborhoods). LCA generated a 5-group model that optimally distinguished opioid users in pregnancy as follows: short-term analgesia with low comorbidity (group 1), analgesia in young people (group 2), medication for opioid use disorder or unregulated opioid use (group 3), pain management with comorbidity (group 4), and mixed opioid use plus high social and medical needs (group 5). The overall risk of postpartum drug overdose or death was 1.5%. Using the 5-group model, compared with people in group 1, the aRR of overdose or death was highest among those in group 5 (aRR, 14.0; 95% CI, 10.1-19.5), followed by group 3 (aRR, 4.6; 95% CI, 3.3-6.5), group 2 (aRR, 3.3; 95% CI, 2.2-4.7), and group 4 (aRR, 3.2; 95% CI, 2.3-4.4). In this cross-sectional study, distinct groups of people with opioid use in pregnancy were associated with increasing degrees of risk of postpartum drug overdose or death. Group characteristics can be used to identify people with high risk and inform harm reduction, home visiting programs, and other interventions.