Worldwide, a disproportionate burden of HIV, tuberculosis, and hepatitis is present among current and former prisoners. This problem results from laws, policies, and policing practices that unjustly and discriminatorily detain individuals and fail to ensure continuity of prevention, care, and treatment upon detention, throughout imprisonment, and upon release. These government actions, and the failure to ensure humane prison conditions, constitute violations of human rights to be free of discrimination and cruel and inhuman treatment, to due process of law, and to health. Although interventions to prevent and treat HIV, tuberculosis, hepatitis, and drug dependence have proven successful in prisons and are required by international law, they commonly are not available. Prison health services are often not governed by ministries responsible for national public health programmes, and prison officials are often unwilling to implement effective prevention measures such as needle exchange, condom distribution, and opioid substitution therapy in custodial settings, often based on mistaken ideas about their incompatibility with prison security. In nearly all countries, prisoners face stigma and social marginalisation upon release and frequently are unable to access health and social support services. Reforms in criminal law, policing practices, and justice systems to reduce imprisonment, reforms in the organisation and management of prisons and their health services, and greater investment of resources are needed.