Cross-sectional analysis of electronic medical and pharmacy records. To examine associations between use of medication for erectile dysfunction or testosterone replacement and use of opioid therapy, patient age, depression, and smoking status. Males with chronic pain may experience erectile dysfunction related to depression, smoking, age, or opioid-related hypogonadism. The prevalence of this problem in back pain populations and the relative importance of several risk factors are unknown. We examined electronic pharmacy and medical records for males with back pain in a large group model health maintenance organization during 2004. Relevant prescriptions were considered for 6 months before and after the index visit. There were 11,327 males with a diagnosis of back pain. Males who received medications for erectile dysfunction or testosterone replacement (n = 909) were significantly older than those who did not and had greater comorbidity, depression, smoking, and use of sedative-hypnotics. In logistic regressions, the long-term use of opioids was associated with greater use of medications for erectile dysfunction or testosterone replacement compared with no opioid use (odds ratio, 1.45; 95% confidence interval, 1.12-1.87, P < 0.01). Age, comorbidity, depression, and use of sedative-hypnotics were also independently associated with the use of medications for erectile dysfunction or testosterone replacement. Patients prescribed daily opioid doses of 120 mg of morphine-equivalents or more had greater use of medication for erectile dysfunction or testosterone replacement than patients without opioid use (odds ratio, 1.58; 95% confidence interval, 1.03-2.43), even with adjustment for the duration of opioid therapy. Dose and duration of opioid use, as well as age, comorbidity, depression, and use of sedative-hypnotics, were associated with evidence of erectile dysfunction. These findings may be important in the process of decision making for the long-term use of opioids. 4.