HIV infection in the Islamic Republic of Iran is concentrated primarily among intravenous drug users. This study investigated the knowledge, attitudes and practices towards HIV/AIDS prevention of a random sample of prisoners in 5 prisons in Mazandaran province. Of 1760 individuals aged 18–65 years old completing the questionnaire, the mean age was 30.1 (SD 8.1) years (range 18 to 59 years); 95.8% were male. Respondents had an average to fairly good knowledge about HIV/AIDS, with the percentages answering correctly ranging from 11.9% to 85.9%. However many had the misconception that “HIV/AIDS does not influence Iran” and “I will not be infected with HIV/AIDS under any conditions” and 63.6% agreed that lack of religious and moral commitment could spread AIDS infection. HIV/AIDS prevention efforts are needed for prisoners in Mazandaran province.