THE APOCALYPSE WAS on its way, and it would begin in Mexico. Where else? When archaeologists dug up Mayan calendars that ominously seemed to run out in the final days of 2012, some doomsayers predicted the end of the world. To many Mexicans it seemed like just another example of their country’s unending run of bad luck. The steepest recession on the American mainland, a plague of H1N1 swine flu and a deepening war against organised crime had made the preceding few years fairly grim. In 2009 the Pentagon had given warning that Mexico could become a “failed state”. Armageddon would be the icing on the cake.

But it turns out that the Mayan glyphs were misunderstood. The men with magnifying glasses now say that the world is not about to end—in fact, it seems that the Mayans were predicting something more like a renewal or a fresh start. Could the same be true of Mexico?

This special report will argue that there is a good chance of it. Some awful years are giving way to what, if managed properly, could be a prosperous period for Latin America’s second-largest economy. Big, irreversible trends, from a falling birth rate at home to rising wages in China, are starting to move in Mexico’s favour. At the same time the country’s leaders are at last starting to tackle some of the home-grown problems that have held it back.

Many of the things that the world thinks it knows about Mexico are no longer true. A serially underachieving economy, repeatedly trumped by dynamic Brazil? Mexico outpaced Brazil last year and will grow twice as fast this year. Out-of-control population growth and an endless exodus to the north? Net emigration is down to zero, if not negative, and the fertility rate will soon be lower than that of the United States. Grinding poverty? Yes, but alleviated by services such as universal free health care. A raging drug war? The failure of rich countries’ anti-drugs policies means that organised crime will not go away. But Mexico’s murder rate is now falling, albeit slowly, for the first time in five years.

A vast country with deeply ingrained problems and unreformed corners, Mexico could yet squander the opportunities that are coming its way. But there are signs that it is beginning to realise its potential. With luck, the dire predictions made by the Pentagon and others may turn out to be as reliable as a misread Mayan calendar.

Preparing to lead Mexico into this brightening future is the party most associated with its past. The Institutional Revolutionary Party (PRI) ran Mexico without interruption for most of the 20th century, silencing opposition through a mixture of co-option, corruption and occasional violence. Only in 2000 did it give up its grip on power to the conservative National Action Party (PAN), which fielded two presidents in succession: Vicente Fox, a former executive at Coca-Cola, and Felipe Calderón, a lawyer whose father was a founding member of the party. On December 1st Mr Calderón will hand over the presidency to the PRI’s Enrique Peña Nieto, who won a clear election victory on July 1st. A handsome 46-year-old with a gift for communication, Mr Peña claims to be the opposite of the crooked party men who ran the country in its pre-democratic days. But will the change be more than superficial?

Mr Peña says his priority is to make the economy grow faster in order to reduce poverty. Nearly half the population are poor, many of them in the south (see map). To achieve more rapid growth he will need to introduce a series of big economic reforms, some of which Mr Calderón attempted during his presidency, only to see them get stuck in Mexico’s cantankerous Congress. The PRI had hoped to win a majority in the summer’s elections, but it fell short by 11 in the 500-member Chamber of Deputies and by four in the 128-member Senate. In any case, some of the most important reforms will need changes to the constitution, which require a two-thirds majority in Congress. However, Mr Peña has reason to be optimistic. The opposition PAN shares much of Mr Peña’s agenda, and together the two parties have a two-thirds majority in both houses of Congress. A new power to fast-track two bills per congressional session will help. A lot will depend on who ends up leading the PAN, which is restive and rudderless after finishing third in the presidential election. The handover period between July’s election and December’s inauguration has been a model of presidential co-operation. Mr Calderón’s crackdown on Mexico’s vindictive criminals has given him a personal reason to stay on good terms with the new government, to make sure of the protection he and his family will need when he leaves office. Fighting on two fronts Mr Peña’s main problem in Congress may well be his own party. As this special report went to press Congress was about to pass a labour-law reform, which among other things would make hiring and firing easier. But linked measures to make Mexico’s over-mighty unions more transparent and democratic were voted down by congressmen from Mr Peña’s own PRI, which has strong ties to unions. If the unions cannot be tamed, Mr Peña’s other reforms—to open up the monopolised energy sector and overhaul the tax system—may be similarly diluted.

The runner-up in the election was the left-winger Andrés Manuel López Obrador, known as AMLO, who came a very close second to Mr Calderón in 2006 but lost to Mr Peña by 6.8%. After both defeats he claimed fraud. The evidence is thin. The left has about a quarter of the seats in Congress, but many of its congressmen have little patience with AMLO, whose magnetic personality repels as many voters as it attracts.

The government may also face opposition outside Congress. Though a majority of the political class now seems to be convinced of the need for economic reforms along the lines that Mr Peña proposes, the same may not yet be true on the street, in the public universities or in much of the press. “Mexico is a country where doctrine and principle matter more than practical considerations and results,” says Enrique Krauze, a historian. The state-run oil monopoly is the sort of sacred cow that could emit a deafening, destabilising moo if Mr Peña tried to tether it. Mexico City already sees an average of 14 protests a day.

The internet is making politics more unpredictable. During the election campaign Mr Peña paid a disastrous visit to a university and fled after being heckled. This gave rise to an anti-Peña student movement calling itself YoSoy132, or “I am the 132nd” (the initial protest was led by 131 students). It is now capable of summoning large crowds via Twitter and Facebook to march against Mr Peña (and often, it seems, for AMLO). During Mexico’s independence celebrations on September 16th anonymous hackers took down several government websites.

So it will not be an easy ride. Mr Krauze remembers that the optimism when the North American Free-Trade Agreement (NAFTA) came into force in 1994 was quickly punctured by the Zapatista uprising in Mexico’s south on New Year’s Day. “We thought we were there in the first world, on the final lap of our historic marathon. Then on January 1st we woke up to the astonishing news of a rebellion in Chiapas,” he says.

Compare the murder rate and body count of each Mexican state against entire countries with our interactive equivalents map

Mexico has form in turning triumph to disaster, and could yet do so again. Its economy remains dependent on the fortunes of the United States, and financial crises in Europe make investors jittery. Promised reforms will depend on persuading entrenched interests to accept them. Corruption and bad government, especially at the local level, may cause good initiatives to fall at the last hurdle. And the drug war is by no means over. But Mexico deserves a fresh look—not least because its economy is revving up, as the next article explains.