It is now almost certain, as of this writing, that Felipe Calderón, the center-right candidate of the National Action Party in Mexico’s presidential election, has beaten Andrés Manuel López Obrador, the left-wing candidate of the Revolutionary Democratic Party, by a tiny margin.

The optimistic view is that Mr. López Obrador was gloriously defeated by Mr. Calderón, a modernizing reformer. But pessimists will point out that a third of all Mexicans voted for Mr. López Obrador, and between a fifth and a quarter for the center-left PRI (the third party in the race). This means that the majority remains divided between the kind of left-wing populism that has kept Mexico underdeveloped—now represented by Mr. López Obrador—and the PRI, a complex system of vested interests responsible for blocking every attempt at reform made by President Vicente Fox over the last six years. Both optimists and pessimists have a point.

Indigenous mythology and Western-style social utopianism—of the kind that pits good revolutionaries against evil reactionaries, and local values against foreign perversions—tend to produce populist messiahs like Mr. López Obrador. In the early 1900s, Mexican folktales began to be recorded again after a three-century hiatus. Many evoke a local king – reminiscent of Montezuma, the Nahua ruler defeated by the conquistadors in the 16th century—who has gone underground, but who will one day come back to save his people. Many of Mr. López Obrador’s voters see him as that sort of redeemer.

Mr. López Obrador represents a renunciation of the idea that development comes from transferring responsibility from the state to civil society and embracing a full exchange with the world. He offered a presidency favoring popular legitimacy over institutional checks and balances (witness his promise to use referendums); a government that acts as the engineer of social justice (hence his promise to give a 20% raise to anyone earning under $800, and to spend $8 billion in social programs and another $20 billion in infrastructure projects); and limits to foreign capital (as in his idea to keep oil and electricity in "national"—that is, government—hands).

It is unlikely that Mr. López Obrador would have become a full member of the "axis" formed by Hugo Chávez, Fidel Castro and Evo Morales, for the same reasons the PRI kept away from communist alliances when it dominated Mexico: Mexican nationalism. But a populist victory in Mexico would have invigorated other populists in Latin America. And the demagogic foreign policy establishment that used to be part of the PRI state would have likely come back, straining relations with the U.S.

Felipe Calderón, by contrast, understands the stakes better than the man he barely beat. Yet there is no guarantee that he will be a more effective reformer than Mr. Fox. The paralyzing dynamics in Congress, where Sunday’s election did not produce a working majority, will pose major obstacles. Mr. Calderón is aware of how, in recent decades, South Korea, China, Spain, New Zealand, Ireland, Estonia and others joined what he calls "the top of the league" by unleashing entrepreneurial drive and creating conditions for capital accumulation. "I am tired of seeing Mexico in the middle of the table," he told me a few weeks ago. "It is time to jump to the top." And he seems eager to try. But if he is to prevent the populists from overwhelming his government and winning next time, he needs to look at why so many Mexicans voted for Mr. López Obrador and the PRI.

Mexican voters would have shunned Mr. López Obrador altogether were it not for the shortcomings of the reforms of the last two decades. What those reforms left untouched is as important as what they modified. Yes, financial stability was achieved and has been maintained—Mexican bonds had a maximum maturity of only one year in 1985; the figure today is 20 years. And, yes, hundreds of inefficient companies were privatized and trade was liberalized to a significant extent. But the economy continued to suffocate under heavy taxation, government-protected monopolies, labor legislation whose rigidity is surpassed only by sub-Saharan Africa, and, above all, the absence of the rule of law. The result has been a socioeconomic system that is not productive or competitive enough.

Between the early ’80s and the beginning of the new millennium, per capita GDP experienced zero growth. It has picked up a bit in the last three years, mostly due to spectacularly favorable international conditions. The small reduction in extreme poverty experienced lately is due to cash transfers that provide temporary relief. Millions have survived only through the informal economy (that employs a majority of the workforce), remittances from migrants, and bribery. A study by the private-sector Center for Economic Studies indicates that 34% of businesses paid $11.2 billion in bribes in 2004.

Mr. Fox’s presidency has contributed to the resurgence of Mexican populism: He has undertaken no substantial economic reform, so millions of frustrated voters were ready to jeopardize political gains for the sake of populist expediency. It is true that the PRI blocked most attempts at reform in Congress these last six years—but in a country where the presidency continues to be exceptionally powerful and the states depend on the federal government even for the collection of local taxes, that is only an excuse. The leadership just wasn’t there.

According to the International Institute for Management Development, Mexico ranks 56th out of 60 countries in terms of competitiveness. To be competitive, a country must provide a secure legal environment in which companies have the expectation of profitable returns. Many companies have migrated from Mexico to China because of high transaction costs. Even when capital does come in (Mexico received a respectable $18 billion in FDI last year), the corporatist, mercantilist system holds back social mobility and productivity (which has grown at an average of only 1.2% a year in the last decade). Mr. Calderón must tackle a number of these bottlenecks if Mexico is to join the top of the league. The justice system, the tax code, labor laws, the pension scheme and the energy sector—monopolized by a government-owned company responsible for keeping the industry undercapitalized—need be opened up to serious market competition. All of this amounts to reforming the state. Quántica Consultores, a consulting firm, found that the two poorest quintiles of the population receive, in per capita terms, 21% of the benefits of government "social" spending while the top two quintiles get 40%.

When Hernán Cortés conquered Mexico, Montezuma mistook him for Quetzacoatl, the divine ruler of the ancient Toltecs who, according to legend, had disappeared. He paid for his mistake. Five centuries later, a majority of Mexican voters seem to have learned the lesson and take Mr. López Obrador for what he really is. Let us hope Mr. Calderón rewards them with a first-class package of reforms that makes sure Mr. López Obrador never comes within an inch of the Mexican presidency again.