A self-reported behaviour survey using an anonymous critical incident based questionnaire was administered by trained interviewers in 1998. Five hundred and thirty-one homosexual and bisexual men were recruited from gay bars, clubs, cafes, a sauna and 'cruising ground' in central Edinburgh. The use of alcohol and recreational drugs and details of sexual activity over the preceding three months and at the last sexual encounter were recorded. Unsafe sex was defined as anal sex without the use of a condom with a partner of unknown or different HIV status. Safer sex was defined as all other types of sex, including anal sex with a condom and anal sex without a condom with a partner whose HIV status was known to be the same. Of the questionnaires completed, 506 were suitable for analysis; 29 men (6.1%) reported anal sex with a partner of unknown or different HIV status without a condom ('unsafe sex') during their last sexual encounter. A total of 53 men (10.5%) could recall an episode of unsafe sex within the last three months. Men who had used marijuana or inhaled nitrites ('poppers') less than two hours before sex, or whose sexual partners had done so, were more likely to have unsafe sex than those who had not. Although alcohol use was more likely before sex with casual partners, the use of alcohol less than 2 hours before sex was not associated with sex being unsafe.