We analyzed serum 25(OH) cholecalciferol [25(OH)D] levels and factors related to deficiency (<20 ng/ml) or insufficiency (<30 ng/ml) in a cohort of Spanish HIV-infected patients and compared them with an age- and latitude-matched population from another study. We prospectively assessed 25(OH)D deficiency/insufficiency in a cohort of 352 HIV patients during 2009-2010. Predisposing factors were recorded and their relationship to low levels was assessed by logistic regression; a nutritional survey examined intake, nutritional status, and sunlight exposure in a subgroup of 92 patients. We studied the correlation of 25(OH)D with parathyroid hormone (PTH) and alkaline phosphatase. Age-, sex-, and race/ethnicity-adjusted vitamin D deficiency (<20 ng/ml) was 44.0% (95% CI, 38.8-49.4%) and insufficiency (<30 ng/ml) was 71.6% (95% CI, 66.9-76.3). Deficiency was 16.4% more prevalent in our sample than in non-HIV-infected Spaniards. Lower sunlight exposure was the only factor related to lower levels in the lifestyle and nutritional survey (p=0.045). In multiple logistic regression, higher body mass index (BMI), black race/ethnicity, lower seasonal sunlight exposure, men who have sex with men (MSM), and heterosexual transmission categories, efavirenz exposure and lack of HIV viral suppression were independently associated with deficiency/insufficiency. These variables predicted 79% of cases [AUC=0.872 (95% CI, 0.83-0.91)]. Patients receiving protease inhibitors (PIs) [OR 4.0 (95% CI, 1.3-12.3); p=0.014] or NNRTI [OR 3.6 (95% CI, 1.7-11.2); p=0.025] had higher odds of increased PTH levels; this was significant only in 25(OH)D-deficient patients (p=0.004). As in less insolated areas, the prevalence of vitamin D deficiency/insufficiency was high in HIV-infected patients in Spain; among treated patients, levels were higher with PIs than with efavirenz.