Background: Male patients with genital warts are known for higher rates of sexual dysfunction. This study was conducted to investigate whether human papillomaviruses (HPV) infection is associated with an increased risk of erectile dysfunction (ED). Methods: Patients aged over 18 with HPV infection (n = 13,296) and propensity score-matched controls (n = 53,184) were recruited from the Longitudinal Health Insurance Database (LHID). The primary endpoint was the diagnosis of ED. Chi-square tests were used to analyze the distribution of demographic characteristics. The Cox proportional hazards regression was used to estimate the hazard ratios (HRs) and 95% confidence intervals (CIs) for the development of ED in both groups, after adjusting for sex, age, relevant comorbidities, co-medication, and surgery. Results: ED developed in 181 patients of the study group. The incidence density of ED was 2.53 per 1000 person-years for the HPV group and 1.51 per 1000 person-years for the non-HPV group, with an adjusted HR (95% CI) of 1.63 (1.37–1.94). In stratification analysis, adjusted HR of diabetes-, chronic obstructive pulmonary disease (COPD-), and stroke-subgroup were 2.39, 2.51, and 4.82, with significant p values for interaction, respectively. Sensitivity analysis yields consistent findings. Conclusions: The patients with HPV infection had a higher risk of subsequent ED in comparison to the non-HPV controls. The mechanism behind such association and its possible role in ED prevention deserves further study in the future.