Over the last year, Mexico has suffered from a seemingly never-ending list of escapes, riots and murders in its prisons. In October 2008, prison inmates hurled grenades and sprayed Kalashnikov rounds at each other in a penitentiary in the Pacific state of Sinaloa. A month earlier, federal police stormed a rioting jail in the border city of Tijuana, resulting in the death of 23 prisoners. Just this past May, in the mining town of Zacatecas, 53 inmates simply walked out of a jail, leaving in a 17-car convoy backed by a helicopter.

The country's penitentiary system has been flooded by new inmates locked up in President Felipe Calderon's war on drug cartels. Calderon boasts his military offensive has netted more than 45,000 cartel operatives from smugglers to gun-toting hitmen to diamond-clad capos. But, now, where does he put them all? A few dozen of the top dogs have been extradited to the United States and some other ranking members have been put in a specially built 800-prisoner capacity top security penitentiary in Mexico State. But tens of thousands of more convicts are shunted into state and city jails across the country, causing record overcrowding and overwhelming ill-equipped local guards. (See pictures from Mexico's drug wars.)

"The problem affects basic things like just not having enough water for all the inmates," says Deputy Warden Jose Luis Herrera, who let TIME inside one of the wings of Mexico City's Eastern Prison  the most populous jail in all of Latin America. "Then we have visiting hours when tens of thousands of family members can show up." Opened in 1976, the prison in the capital's rough Eastside was built for 4,700 prisoners. It currently has 12,500 inmates.

In face of the challenge, U.S. officials have earmarked $4 million to help bolster Mexican prisons, part of an aid package to support the fight against the drug armies. Calderon has also promised to build more pens to cope with the burgeoning numbers. But some working in the prison system say the difficulties in the controlling the inmates will not be solved by raising more jail houses; the crisis, they say, also stems from profound problems in Mexico's justice apparatus. More than 41% of the nation's total prison population of 220,000 has not even been convicted and sentenced even though many of the prisoners have already spent several years behind bars. "There should be less focus on trying to put more people in prison and more on trying to get the right people in," Deputy Warden Herrera says. (Watch TIME's video "Inside Mexico's Overcrowded Prisons.")

Mexico also struggles with corruption among prison officials, some of whom are susceptible to the influence of their prisoners  especially the traffickers from the multi-billion dollar narcotics industry. For example, the escape of the 53 prisoners at Zacatecas was clearly an inside job: a closed circuit video showed guards sitting and watching as the escapees marched out of the cells into the waiting convoy. The warden and several guards have since been arrested, though they have yet to be charged. Many of the escapees were members of the Zetas, a feared drug paramilitary based over the border from Texas. The gang is alleged to organize inmates inside several penitentiaries especially in northern Mexico. A fight between alleged Zeta prisoners and a rival gang left 21 dead in a deadly fight in October in a prison in Reynosa, across the bridge from McAllen, Texas.

Criminals still run their operations from behind bars. They communicate with their colleagues by way of visiting family members and lawyers; but the crooks have often been found with cell phones smuggled passed the barbed wire fences and watch towers. Phone calls have even been traced to attempts to extort ransoms from terrified victims on the outside. The Eastern Prison is currently installing a new security device to block cell phone signals inside the prison walls. (See pictures of crime-fighting in Mexico City.)

Drug gangs also peddle their narcotics to the bored and frustrated inmates, many of whom were already addicted on the outside. Convicted car thief Jair Lopez says crack cocaine is easily available in the Eastern Prison helping him fuel his addiction. "It is tough in here any way. But when you're walking round high on drugs it just gets you in more trouble," Lopez says, resting in a sun scorched prison yard after doing chin ups on a rusty metal bar.

A stocky 29-year old, Lopez recently volunteered to go to a special rehab wing with hundreds of other inmates trying to stay clean. To keep their minds off the rocks and powders, they submit to a rigorous exercise therapy, including running round the yard shouting marine-like chants. Officials say the program has helped reduce prison violence.

However, such programs are scarce in Mexico's many provincial prisons, where inmates have almost no help to kick the habits. Most of the 43 riots and 22 escapes this year were in prisons in the arid north of Mexico where the drug trade is concentrated. With thousands more cartel soldiers flooding into these same jails, pundits fear the worst may be yet to come. "Mexico's prisons are a powder keg," wrote syndicated Mexican columnist Hugo Sanchez Gudino. "Sooner or later they are going to explode."