Background and aims: Evidence suggests strong a relationship of vitamin D deficiency (VDD) with erectile dysfunction (ED) in men. The prevalence and long-term complications of diabetes are being recognize more increasingly that has the possible association again with VDD. Thus, the study aimed to find out the association between VDD and ED among Bangladeshi adult men with type 2 diabetes. Materials & Methods: This nested case-control study recruited 2860 adult patients with type 2 diabetes mellitus (T2DM) who had ED (aging between 30 -69 years). The patients who found to have normal vitamin D level, were taken as control and those had VDD, were categorized as the case. The study was conducted in eight diabetes care centers of Bangladesh. Socio-demographic and personal information of the respondents were collected by faceto-face interview and disease-specific data were recorded from the patient's diabetic record book. The bodyweight, height, waist circumference, hip circumference and blood pressure were also recorded. Fasting blood sample was collected to estimate serum levels of vitamin D, glucose, and free testosterone. Results: The diabetes patients with ED had more severe VDD [(25 OH)D <10 ng/mL] than the controls (61.28% and 62.16%, respectively). The more severe form of ED found in the lower levels of serum vitamin D. A linear relationship of VDD was found with ED [OR 2.83, CI 2.36, 3.97] in multivariate logistic regression analysis. Conclusions: Vitamin D deficiency is an independent risk factor of ED in men with type 2 diabetes mellitus and severity of ED is linearly associated with the degree of deficiency of vitamin D.