Then, three years ago, the government tore down the shacks and built a bustling new neighborhood of concrete apartment buildings, freshly paved streets, basketball courts and fields with artificial turf.
"We live more decently here now. People see a prettier neighborhood, kids playing soccer," said Ronny Murillo, a 45-year-old ex-convict who helped build one of the billions of dollars in projects made possible by an economic boom driven largely by the $5.25 billion expansion of the Panama Canal. Behind him, enormous cranes loomed over a skyline that has been transformed by dozens of new skyscrapers, many filled with luxury apartments, high-end stores and fashionable boutiques.
In a little more than five years, Panama has slashed its unemployment rate by two-thirds and nearly tripled the rate of government spending as the double-digit growth of the canal-fueled boom has made it the hemisphere's hottest economy. Just to the north, Nicaragua has watched years of slower growth fail to move it out of its position as the hemisphere's second-poorest nation, after Haiti.
The deep discrepancy between the fortunes of two Central American neighbors goes a long way toward explaining the Nicaraguan government's fervent promotion of a Chinese company's vague proposal to build the hemisphere's second trans-ocean canal across Nicaragua.
Underlying much of the enthusiasm in Nicaragua is the hope that the massive new canal could bring a bit of Panama-style prosperity.
"I don't think we're going to be just like Panama, because they're already 100 years ahead of us. But yes, I think this is going to help Nicaragua put poverty behind it and generate jobs," said Roberto Pasquier, an electric appliance salesman in a market in the Nicaraguan capital, Managua.
Panama's prosperity has drawn tens of thousands of job-seekers, mostly from Nicaragua and nearby Colombia, Venezuela and the Dominican Republic. Almost 40,000 such workers have been granted legal status in Panama since 2010 under a government program meant to feed the roaring demand for labor to build projects that include Central America's first subway, a $1.452 billion investment.
Panama has the highest level of human development in Central America according to the United Nations Development Program, which measures factors including life expectancy, health care access and education.
"You can make money here in Panama, buddy," said Mauricio Hernandez, a 29-year-old Colombian who sells food in the streets of Panama City. "We're all coming for dollars."
Panamanian Abel Aparicio, a 49-year-old hotel chef, earns $1,000 a month, twice what he made when he started 20 years ago, and has bought two small apartments that he rents out to supplement his income.
"Nobody's that worried about losing their job," he said. "If you leave one job, other opportunities open up, and there are ways to make money besides hotels, which there are a lot of these days," he said.
Panama's economy started booming around the time that authorities began the Panama Canal expansion in 2007. By 2010, the annual growth rate rose to around 10 percent, where it's stayed.
The canal expansion generated 30,000 direct jobs and the administration of populist right-leaning President Ricardo Martinelli estimates that the government will have put $16 billion into public works between 2009 and 2014. That amount was $4.4 billion between 2000 and 2004. A 13.5 percent unemployment rate in 2004 dropped to 4.6 percent in 2012, in a workforce of 1.6 million. The poverty rate dropped from 36 percent in 2002 to 26 percent today.
Wealthy investors, many from Colombia and Venezuela, have built real-estate and tourism projects, restaurants, clothing stores, car dealerships and computer businesses around Panama City.
Nicaragua, meanwhile, doesn't have any obvious means, besides the possibility of the canal, of rapidly accelerating its growth.
The government says it has created 700,000 jobs since President Daniel Ortega took office in 2007 and poverty has dropped from 50 percent in 2006 to 42 percent last year. But 1 million people remain out of work in a country of 6 million. If the canal is built, the Nicaraguan government says, within five years GDP would go from $11 billion a year to $25 billion, generating hundreds of thousands of new jobs.
"Those who oppose the canal want this country to keep suffering from underdevelopment and poverty," said Edwin Castro, congressional leader of Ortega's Sandinista Front.
Nicaragua is betting on businessman Wang Jing, who first appeared in Nicaragua last year as the head of the Xinwei Telecom Enterprise Group, which signed a contract with the government to improve the country's telecommunications system and promised to invest as much as $700 million dollars. So far, there's virtually no sign of any spending yet.
"We can't believe that they're going to build an inter-ocean canal, when from here it looks like they haven't even built a single telephone line, or done anything else since they made the announcement. It's all a lie," said opposition congressman Eliseo Nunez.
The head of Nicaragua's state telecommunications institute told reporters last week that the first new telecommunications antennas would be installed by Xinwei in late July or early August, and the delay had been caused by Xinwei's high manufacturing standards. Still, such problems have fueled widespread doubts inside Nicaragua, where many are skeptical about dreams of Panama-style riches.
"It's all a grand illusion that they're selling us, it's untrue that we're going to turn into another Panama," taxi driver Francisco Siles said as he picked up fares outside a Managua hospital. "We're going to keep being the same poor Nicaragua."
Weissenstein reported from Mexico City. Luis Manuel Galeano contributed from Managua, Nicaragua, and Kathia Martinez contributed from Panama City.