Although opioids are initiated on hospital discharge in millions of older adults each year, there are no studies examining patient- and prescribing-related risk factors for opioid-related adverse drug events (ADEs) after hospital discharge among medical patients. A retrospective cohort study of a national sample of Medicare beneficiaries aged 65 years and older, hospitalized for a medical reason, with at least one claim for an opioid within 2 days of hospital discharge. We excluded patients receiving hospice care and patients admitted from or discharged to a facility. We used administrative billing codes and medication claims to define potential opioid-related ADEs within 30 days of hospital discharge, and competing risks regression to identify risk factors for these events. Among 22,879 medical hospitalizations (median age 74, 36.9% female) with an opioid claim within 2 days of hospital discharge, a potential opioid-related ADE occurred in 1604 (7.0%). Independent risk factors included age of 80 years and older (HR 1.18, 95% CI 1.05-1.33); clinical conditions, including kidney disease (HR 1.22, 95% CI 1.08-1.37), dementia/delirium (HR 1.38, 95% CI 1.22-1.56), anxiety disorder (HR 1.20, 95% CI 1.06-1.36), opioid use disorder (HR 1.20, 95% CI 1.03-1.39), intestinal disorders (HR 1.31, 95% CI 1.15-1.49), pancreaticobiliary disorders (HR 1.32, 95% CI 1.09-1.61), and musculoskeletal and nervous system injuries (HR 1.35, 95% CI 1.17-1.54); red flags for opioid misuse (HR 1.37, 95% CI 1.04-1.80); opioid use in the 30 days before hospitalization (HR 1.20, 95% CI 1.08-1.34); and prescription of long-acting opioids (HR 1.34, 95% CI 1.06-1.70). Potential opioid-related ADEs occurred within 30 days of hospital discharge in 7.0% of older adults discharged from a medical hospitalization with an opioid prescription. Identified risk factors can be used to inform physician decision-making, conversations with older adults about risk, and development and targeting of harm reduction strategies.