Context Erectile function is important for life satisfaction and often impaired in men with obstructive sleep apnea (OSA). Uncontrolled studies show that treating OSA with continuous positive airway pressure (CPAP) improves erectile function. Phosphodiesterase type 5 inhibitors (e.g., vardenafil) are the first-line therapy for erectile dysfunction (ED), but may worsen OSA. Objective To assess the effects of CPAP and vardenafil on ED. Design Sixty-one men with moderate-to-severe OSA and ED were randomized to 12 weeks of CPAP or sham CPAP, and 10 mg daily vardenafil or placebo in a two-by-two factorial design. Main Outcome Measures International Index of Erectile Function (primary end point), treatment and relationship satisfaction, sleep-related erections, sexual function, endothelial function, arterial stiffness, quality of life, and sleep-disordered breathing. Results CPAP increased the frequency of sleep-related erections, overall sexual satisfaction, and arterial stiffness but did not change erectile function or treatment or relationship satisfaction. Vardenafil did not alter erectile function, endothelial function, arterial stiffness, or sleep-disordered breathing, but did improve overall self-esteem and relationship satisfaction, other aspects of sexual function, and treatment satisfaction. Adherent CPAP improved erectile function, sexual desire, overall sexual, self-esteem, relationship, and treatment satisfaction, as well as sleepiness, and quality of life. Adherent vardenafil use did not consistently change nocturnal erection quality. Conclusion CPAP improves overall sexual satisfaction, sleep-related erections, and arterial stiffness. Low-dose daily vardenafil improves certain aspects of sexual function and did not worsen OSA. Adherent CPAP or vardenafil use further improves ED and quality of life.