Background and aims: Several recent studies found strong relationship of vitamin D deficiency (VDD) with erectile dysfunction (ED). The morbidity of men with diabetes is also becoming more increasingly recognized which has been taken to have association again with VDD. The aim of this study was to determine the association between vitamin D status and ED Bangladeshi adult men with type 2 diabetes. Materials & Methods: The nested case-control study included 2860 patients with type 2 diabetes mellitus (T2DM) who had ED (aging between 30 to 69 years). The patients who found to have normal vitamin D level, were categorized as control and those who had VDD, were grouped as the case. The study was conducted in eight diabetes care centers, one from each of the eight administrative divisional cities of Bangladesh. Socio-demographic and personal information were collected by face to face interview and disease-specific data were recorded from the patient’s diabetic record book. Body weight, height, waist circumference, hip circumference and blood pressure were also recorded. Fasting blood sample was collected and serum levels of vitamin D, glucose, and free testosterone were measured. Results: The diabetes patients with ED has 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 lowest level of serum vitamin D level. The multivariate logistic regression analysis found VDD has linear relationship with ED [OR 2.83, CI 2.36, 3.97]. 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.