Background: The epidemiology of chronic hepatitis B (CHB) in Spain has changed due to migratory movements and the implementation of vaccination programs. The objective is to determine if prevalence has also changed amongst in Catalonia and the potential predictive variables of the infection. Material and method: Observational cross-sectional multi-centre study of CHB prevalence. Epidemiological and clinical variables were included, and their predictive capacity is analysed by means of a multivariable logistic regression model. Results: A total of 6508 prisoners were studied. CHB prevalence was 1.7%, much less than in studies carried out in previous years. In inmates from North Africa, Asia, Eastern Europe, and Sub-Saharan Africa the CHB rate was 2.8, 4.2, 4.9 and 16.2 times higher, respectively, than amongst those born in Spain, which was 0.6%, the same as in the general population. CHB was associated with: a) being an immigrant [2.6%; OR: 4.18 (CI: 2.50-6.90; P <0.001); b) being unvaccinated (3.1%; OR: 0.13; CI: 0.06-0.26; P <0.001); and c) being infected by the human immunodeficiency virus (HIV) [3.9%; OR: 3.23; CI: 1.24-8.40; P = 0.016]. Conclusion: Vaccination against HBV (hepatitis B virus) has greatly reduced CHB prevalence in inmates over the past 30 years but remains high in immigrants and those with HIV. We recommend: a) maintaining HBV screening amongst inmates; b) continuing with vaccination programmes; and c) referring CHB cases to specialized programs for further study and treatment if needed.