Background This study was undertaken in order to identify the prevalence and factors associated with depression in a group of patients with type 2 diabetes mellitus. Methods Our design consisted of a cross-sectional study at the Department of Neurology and Psychiatry of the Instituto Nacional de Ciencias Médicas y Nutrición Salvador Zubirán in Mexico City. Study units included 189 patients with type 2 diabetes mellitus (DM). Beck Depression Inventory scale was used to measure the presence of depression, while the independent variables evaluated to explain depression were sociodemographic (gender, marital status, religion, education, occupation, socioeconomic status) and characteristics of the disease were disease duration, comorbidity, compliance, and glycemic control. Results Prevalence of depression was 39% (74 patients). The following risk factors were identified by univariate analysis: being widowed (OR 3.54, confidence interval [CI] 1.56–8.11, p = 0.0007); female (OR 2.95, CI 1.50–5.82, p = 0.006); housewife (OR 2.08, CI 1.10–3.94, p = 0.01); poor compliance (OR 2.14, CI 1.12–4.10, p = 0.01), and presence of comorbidity (OR 5.60, CI 1.51–24.5, p = 0.002). On the other hand, the most constant associations were presence of blood glucose at the last appointment ≥200 (OR 3.23, CI 1.59–6.60, p = 0.0003) and ≥250 (OR 2.15, CI 0.93–5.03, p = 0.05), as the average of the last five blood glucoses ≥200 (OR 3.67, CI 1.76–7.73, p = 0.0001), ≥250 (OR 4.07, CI 1.61–10.49, p = 0.0007) and ≥300 (OR 2.12, CI 1.48–3.02, p = 0.003). Discriminant function analysis of the variables, previously studied in univariate analysis, was carried out for the presence of depression. A stepwise model included the following variables: average of the last five blood glucoses; 2) widowed or divorced, and 3) female. Conclusions Frequency of depression in patients with type 2 DM was high (39%). High level of blood glucose stands out as a variable associated with presence of depression. Other associations were presence of comorbidity, being a female, and being widowed or divorced.