Haemorrhoids are associated with regional vascular abnormalities and rectal pain, which are hypothesized to increase the risk of erectile dysfunction (ED); however, few studies have investigated the association between ED and haemorrhoids. This case-control study aimed to estimate the association between haemorrhoids and ED by using a population-based data in Taiwan. We identified 6 310 patients with ED as cases and randomly selected 31 550 controls. Conditional logistic regression was performed to compute the odds ratio (OR) for having been previously diagnosed with haemorrhoids between cases and controls. The results show that haemorrhoids were found to be present among 1 572 (24.9%) cases and 4 491 (14.20%) controls. The OR for prior haemorrhoids among cases was 1.90 (95% CI = 1.78-2.03) when compared with controls after adjusting for monthly income, geographical location, hypertension, diabetes, coronary heart disease, hyperlipidemia, obesity and alcohol abuse/alcohol dependence syndrome. Younger cases demonstrated a higher risk for prior haemorrhoids when compared with controls. In particular, the adjusted OR among cases <30 years old was 3.71 (95% CI = 2.74-5.02) when compared with controls. We concluded that there was an association between ED and a prior diagnosis of haemorrhoids.