IMPORTANCE Tramadol is a weak opioid analgesic whose use has increased rapidly, and it has been associated with adverse events of hypoglycemia. OBJECTIVE To assess whether tramadol use, when compared with codeine use, is associated with an increased risk of hospitalization for hypoglycemia. DESIGN, SETTING, AND PARTICIPANTS A nested case-control analysis was conducted within the United Kingdom Clinical Practice Research Datalink linked to the Hospital Episodes Statistics database of all patients newly treated with tramadol or codeine for noncancer pain between 1998 and 2012. Cohort and case-crossover analyses were also conducted to assess consistency of the results. MAIN OUTCOMES AND MEASURES Cases of hospitalization for hypoglycemia were matched with up to 10 controls on age, sex, and duration of follow-up. Odds ratios (ORs) and 95% confidence intervals (CIs) were estimated comparing use of tramadol with codeine. A cohort analysis, with high-dimensional propensity score-adjusted hazard ratios (HRs) and 95% CIs, was performed comparing tramadol with codeine in the first 30 days after treatment initiation. Finally, a case-crossover analysis was also performed, in which exposure to tramadol in a 30-day risk period immediately before the hospitalization for hypoglycemia was compared with 11 consecutive 30-day control periods. Odds ratios and 95% CIs were estimated using conditional logistic regression analysis. RESULTS The cohort included 334 034 patients, of whom 1105 were hospitalized for hypoglycemia during follow-up (incidence, 0.7 per 1000 per year) and matched to 11 019 controls. Compared with codeine, tramadol use was associated with an increased risk of hospitalization for hypoglycemia (OR, 1.52 [95% CI, 1.09-2.10]), particularly elevated in the first 30 days of use (OR, 2.61 [95% CI, 1.61-4.23]). This 30-day increased risk was confirmed in the cohort (HR, 3.60 [95% CI, 1.56-8.34]) and case-crossover analyses (OR, 3.80 [95% CI, 2.64-5.47]). CONCLUSIONS AND RELEVANCE The initiation of tramadol therapy is associated with an increased risk of hypoglycemia requiring hospitalization. Additional studies are needed to confirm this rare but potentially fatal adverse event.