These photographs by AFP photojournalist Noel Celis reveal the shocking conditions in an overcrowded prison near Manila in the Philippines.

Quezon City Jail was built six decades ago to house 800 prisoners. It now accommodates 3,800 men, who who compete endlessly for space. Inmates take turns to sleep on the floor of an open-air basketball court, on the steps of staircases, underneath beds, and in hammocks made out of old blankets. Their bodies are packed together like sardines, unable to stretch out.

When it rains – and the Philippines is renowned for torrential storms – conditions become even worse because inmates cannot sleep in the open air. The government provides a daily budget of just 50 pesos (about 80p, or $1.10) for food and five pesos (8p) for medicine per inmate, according to an AFP report.

There is just one toilet for every 130 men, and buckets of water are used to flush them. The stench is compounded by rotting rubbish in a nearby canal.

The Philippine penal system is the third most congested in the world, according to the University of London's Institute for Criminal Policy Research. Jails nationwide have nearly five times more inmates than they were built for, according to government data.

Conditions in the prison are getting worse as police wage a brutal war on crime. Security forces have killed hundreds of people and detained thousands more in just one month as they have followed the orders of President Rodrigo Duterte, who has said the top priority at the start of his six-year term is to eliminate drugs in society.

Former inmate Raymund Narag is now a criminal justice scholar at the Southern Illinois University in the United States. He was locked up in Quezon City Jail in 1995 as a 20-year-old after being accused of killing a student from a rival college fraternity. It took seven years for a court to acquit him, which is about the average length of a trial in the Philippines and one of the main drivers of the overcrowding problem.

Narag told AFP: "If there are no new jails, no budget increases, no additional courts and prosecutors, the system will explode. That will be a humanitarian crisis."