The aim of this cross-sectional study was to analyse the prevalence of HIV-1 drug-resistance mutations among HIV-1-infected prison inmates in Spain. Treatment-naive and treatment-experienced patients with an HIV RNA viral load of >/=2,000 copies/ml were included. To ensure that the study population was representative of the entire HIV-infected Spanish inmate population, a two-stage conglomerate for selection of the sample was used. In the first stage, 15 prisons were randomly selected, and in the second stage, 38 patients (30 treatment-experienced and 8 treatment-naive) per centre were randomly selected. Genotyping was performed by automatic sequencing. Resistance testing was performed on viral strains from 184 inmates from 12 prisons. Valid sequences were obtained from 133 inmates (90 treatment-experienced and 43 treatment-naive inmates). Most (92.5%) were men and had acquired HIV infection by intravenous drug use (91%); their mean age was 35 years. One or more key resistance mutations were detected in 5 (11.6%) treatment-naive and in 35 (38.6%) treatment-experienced patients. Among treatment-naive and treatment-experienced patients, resistance to nucleoside reverse transcriptase inhibitors was found in 3 (6.9%) and in 20 (22.2%) patients, respectively, resistance to non-nucleoside reverse transcriptase inhibitors in 3 (6.9%) and in 21 (23.3%) patients, and resistance to protease inhibitors in 3 (6.9%) and in 14 (15.5%) patients. Multidrug resistance was detected in 1 of the 43 (2.3%) treatment-naive patients. These findings support the use of resistance testing in HIV-infected inmates who must begin antiretroviral therapy, given the high rate of primary resistance to drugs frequently included in the initial treatment regimens.