Inmates dressed as beauty queens pranced on a makeshift stage for a mock beauty pageant at a

Thousands cheered and whistled as 11 gay and one transgender prisoner danced and sang at the "Miss Universe" pageant at the Quezon City Jail courtyard, wearing wigs, make-up, gowns and elaborate Mardi Gras attire.

The decaying Manila jail, housing about 3,800 inmates, is infamous for congestion. Men take turns sleeping in the cells, an open-air basketball court and even on stairways of the facility, built to hold 800 prisoners.

"It's lonely in here but I'm happy that I won," the winner called Gwen, whose real name cannot be used due to prison policy, told AFP.

Gwen, arrested nearly two years ago and on trial for drug dealing, said his victory had brought "acclaim for my brigade", referring to his gang.

All 12 of the gangs in the prison were allowed to enter one contestant to the gay beauty pageant, organised by a jail contractor.

"This is part of inmate welfare development. Once they join activities like this they get less jail time through the good conduct time allowance law," said the service provider, Ferdinand Abejon.

The Quezon City Jail holds defendants of criminal cases but who have not yet been convicted. Due to overburdened courts many of the inmates have been locked up there for years.

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, government data shows.

The situation is set to get much worse with police having arrested more than 40,000 suspects since Philippine President Rodrigo Duterte launched a war on drugs that has also left more than 5,300 people dead since July.

The real Miss Universe pageant is a popular contest in the Philippines, with Filipina beauty queen Pia Wurtzbach winning the crown last year.

Manila is hosting the annual contest next month.