In Italy, the prevalence of non-B HIV-1 subtypes ranges reportedly from 5.4% to 12.6%, yet there are no data on their circulation in prisons, where the prevalence of HIV infection is high. A retrospective study was conducted to evaluate the circulation of non-B subtypes and to characterize their determinants in five Italian prisons. To this end an aliquot of samples of blood was taken in the period 2001-2006 from all 262 HIV-positive inmates in whom antiretroviral treatment had failed. Complete HIV-1 PR and RT regions were sequenced for all samples and subjected to phylogenetic analysis; 250 (95.4%) sequences clustered with subtype B. The non-B subtype was found in 4% of Italian prison inmates and 16.7% of non-Italian prison inmates; the overall percentage increased from 1.8% for inmates infected in 1982-1990 to 4.4% in 1991-1999 and 21.9% in 2000-2006. Factors significantly associated with non-B subtypes were an exposure to other than injecting drug use and a first positive HIV test in 2000-2006. Non-B subtypes were distributed within five monophyletic clades. In all cases but one, it was possible to correlate the history of HIV-exposure to the origin of the clade, with high bootstrap values. In conclusion, although the sample may not be representative of the prison inmate population in Italy, the data suggest strongly that the circulation of non-B subtypes has apparently increased. Non-B subtypes were found to have been associated with heterosexual contact and time of the first HIV-positive test. Knowledge of the different subtypes circulating in prisons may be useful for tracking the epidemiology of HIV infection and for choosing antiretroviral therapy.