OBJECTIVE--To investigate the possible spread of HIV infection and its route of transmission among prison inmates. DESIGN--In response to an outbreak of acute clinical hepatitis B and two seroconversions to HIV infection, counselling and testing for HIV were offered to all inmates over a two week period in July 1993. Information was sought about drug injecting, sexual behaviour, and previous HIV testing. SETTING--HM Prison Glenochil in Scotland. SUBJECTS--Adult male prisoners. MAIN OUTCOME MEASURES--Uptake of HIV counselling and testing; occurrence and mode of HIV transmission within the prison. RESULTS--Of a total 378 inmates, 227 (60%) were counselled and 162 (43%) tested for HIV. Twelve (7%) of those tested were positive for antibody to HIV. One third (76) of those counselled had injected drugs at some time, of whom 33 (43%) had injected in Glenochil; all 12 seropositive men belonged to this latter group. Thirty two of these 33 had shared needles and syringes in the prison. A further two inmates who injected in the prison were diagnosed as positive for HIV two months previously. Evidence based on sequential results and time of entry into prison indicated that eight transmissions definitely occurred within prison in the first half of 1993. CONCLUSION--This is the first report of an outbreak of HIV infection occurring within a prison. Restricted access to injecting equipment resulted in random sharing and placed injectors at high risk of becoming infected with HIV. Measures to prevent further spread of infection among prison injectors are urgently required.