But the situation is probably worse than the numbers suggest. Mr. Rebelo, the union leader, accused the government of manipulating statistics to play down overcrowding. In Mr. Rebelo’s prison, one of Portugal’s newest, the number of inmates is expected to rise to 753 from 630 under a plan to add bunk beds. The prison, in Sintra about 20 miles west of Lisbon, was built in 2004 to hold 600 inmates.

“They’ve changed their calculations for available space from square to cubic meters, so that bodies can basically be piled up while keeping ratios officially unchanged,” he said.

For inmates, it is not just the overcrowding that makes their lives so miserable. “Guards are now working under the worst conditions that I’ve seen — so I’ve got some sympathy for that,” said Carlos Santos, a former inmate. “The real problem is that when guards are in such a bad state of mind, their response is, unfortunately, to pile on the abuses and violence.”

Mr. Santos knows Portugal’s prison system only too well. He was released this year after 18 years spent in five different prisons for crimes that included homicide, drug trafficking and theft. He spent his last year, he said, sharing a two-person cell with five other inmates. In September, inmates staged a strike to denounce beatings by guards, as well as worsening food and sanitary conditions, including having to share cells with inmates with infectious diseases.

Former inmates claim basic items like shampoo and detergent, previously distributed free, must now be bought, from guards who overcharge and pocket the difference. “In a crisis, corruption takes whatever little money is available out of the system,” Mr. Santos said.

Guards say they are as much victims of the country’s economic misery as the inmates. Damaged security cameras go six months without repair or replacement, they say. The maintenance company responsible for keeping prison vehicles operating is refusing to repair any more until it is paid for previous work.

A year ago, when the guards went on strike, the government agreed to hire 240 new ones. The guards say that 800 new recruits are needed to maintain order amid the overcrowding.