The objective of this investigation was to study the prevalence of serological markers of hepatitis B and possible risk factors for this disease in a sample of 404 people who attended a Testing and Couseling Center for HIV in the city of Ribeirão Preto, São Paulo State, Brazil. The overall prevalence of serologic hepatitis B markers was 14.6%, equal to that obtained for anti-HBc. HBsAg and anti-HBc IgM showed prevalences of 1%. After adjustment using logistic regression, hepatitis B markers showed association with the following variables: age, place of residence, use of injectable drugs and positivity to anti-HIV. The overall prevalence of human immunodeficiency virus infection was 6.9%. Hepatitis B markers were detected in 55.6% among intravenous drug users and in 42.9% among those who tested positive for HIV, confirming literature findings which indicates high levels of infection in these specific population groups.