Previous studies have shown that Helicobacter pylori (Hp) infection is associated with erectile dysfunction (ED), but the mechanism is unclear. To assess the relationship between ED and Hp, folic acid (FA), vitamin B12 (B12), and homocysteine (HCY). This study included 84 patients with ED and 42 healthy men. We adopted an IIEF-5 score <21 (5-item International Index of Erectile Function) as the diagnostic criterion for ED, and the RigiScan monitoring device was used to preliminarily screen for and rule out psychogenic ED. Levels of Hp immunoglobulin G (Hp-IgG) titer, FA, B12, and HCY were compared between the ED group and the non-ED group, and the correlation between the indicators was evaluated. The median Hp-IgG titer was higher in the ED group than the control group (32.34 vs 20.88, P < .001). The ED group had lower median levels of B12 (195 vs 338, P < .001) and FA (4.66 vs 10.31, P < .001) and a higher median level of HCY (12.7 vs 8.1, P < .001). Multivariate logistic regression analysis showed that the level of FA (odds ratio,0.111; 95% CI, 0.031-0.399; P < .001) was an independent risk factor for ED. Specifically, FA level was significantly higher in the moderate ED group than the severe ED group, which had a higher median Hp-IgG titer and lower level of B12; although not significant, this was still a clinical trend. Hp-IgG titer was negatively correlated with levels of FA (r = -0.601, P < .001) and B12 (r = -0.434, P < .001) and with the IIEF-5 score (r = -0.382, P < .001) and positively correlated with HCY (r = 0.69, P < .001). The ED group had higher levels of Hp-IgG titer and HCY and lower levels of B12 and FA. This study is the first to link Hp infection, FA, B12, and HCY and further explain the relationship between these indicators and the underlying pathologic mechanisms that jointly cause ED. The limitation is that our study was based on Hp-IgG titers, which do not necessarily represent the full extent of Hp infection, despite the avoidance of invasive testing. Hp infection might lead to decreased FA and B12 and then increased HCY, which might be a mechanism leading to ED. Hp eradication or FA and B12 supplementation might have certain clinical value in the treatment of vascular ED.