Mexico's old rulers have regained power following 12 years in opposition but likely will have to forge alliances with other parties to push through reforms after winning the presidency by a much narrower margin than polls had forecast.
Enrique Pena Nieto of the Institutional Revolutionary Party, or PRI, declared himself the winner of Sunday's presidential election after a quick count by Mexico's electoral authorities gave him a clear lead.
Promising to reinvigorate the economy and reduce rampant drug violence, the telegenic 45-year-old will take office in December for a six-year term as president, restoring the party that dominated Mexican politics for most of the past century, at times ruthlessly.
Opinion polls in the last few days before the election had forecast Pena Nieto winning by a margin of between 10 to 15 percentage points, but with 85 percent of returns in, he was only 5.4 percentage points ahead of his leftist rival, Andres Manuel Lopez Obrador.
Mr. Pena Nieto had 37.6 percent support compared to 32.2 percent for Lopez Obrador and 25.4 percent for ruling party candidate Josefina Vazquez Mota.
"Mexicans have given our party another chance. We are going to honor it with results," a visibly moved Pena Nieto told followers packed inside the PRI headquarters in Mexico City, where confetti rained down on jubilant supporters.
Although Mr. Lopez Obrador said on Sunday night it was too early to concede defeat, a senior electoral official said the PRI candidate's lead was "irreversible" and outgoing President Felipe Calderon congratulated Mr. Pena Nieto on his triumph.
The conservative Calderon's ruling National Action Party (PAN) suffered a crushing defeat, hurt by his failure to bolster economic growth and curb the fierce violence of a drug war that has killed tens of thousands of people and battered Mexico's image.
Mr. Pena Nieto will take over at a time when Mexico's finances are in good order and the economy is beginning to improve, although it still cannot generate enough work for the growing population.
Although the PRI earned a reputation for unscrupulous and often corrupt politics when it ruled between 1929 and 2000, its 71-year stranglehold on power allowed it to sell itself in this campaign as the party that best knows how to govern.
And its candidate, renowned as much for his unfailingly well-groomed appearance as his political skills, persuaded many voters that his party has learned the lessons of its past.
"The PRI have learned to listen to the people, they have learned they are not kings ... to engage with people, understand them, and rule in a coalition with the people," said 20-year-old student Hector Perez.
It was still unclear how the parties would stack up in Congress, but the incomplete results suggested the PRI could struggle to capture a working majority, leaving it reliant on other parties to pursue its reform agenda.
Having run Mexico as a virtual one-party state for most of the 20th century, the PRI was ousted in an election 12 years ago and was seen by many as near death when it finished way back in third place in the 2006 presidential vote.
Mr. Pena Nieto, a handsome former state governor, gave it a presidential candidate to rally around and had led opinion polls for more than two years.
He has promised to lift economic growth to about 6 percent a year, create jobs and draw the heat out of a drug war that has killed more than 55,000 people since late 2006. His main reform proposals include allowing more private investment in Mexico's state-run oil industry.
Mr. Lopez Obrador could still choose to challenge the election, as he did six years ago when he narrowly lost to Calderon and launched months of protests, alleging fraud.
He has said in recent weeks that this election campaign was also plagued with irregularities, raising concerns that he might again call his supporters onto the streets. On Sunday night, he said only that he would wait until all the results are in.
The PAN raised high hopes when it was elected in 2000, but the economy has grown only at an average of 2 percent a year since then and the drug war has battered Calderon's reputation.
"Nothing has improved since the PAN got in," said Mexico City plumber Raimundo Salazar, 44. "The PRI understands how things work here. And it knows how to manage the drug gangs."
Mr. Pena Nieto built his reputation as governor of the State of Mexico in 2005-2011, where he oversaw solid economic growth and brought down the state government's debt.
"He did a really good job ... building lots of hospitals, roads and schools," said Lino Posadas, 30, a parking attendant from the town of San Jose del Rincon in the state.
To his critics, Mr. Pena Nieto is a product created by Mexico's main television companies to serve as a proxy for the country's biggest businesses and the ruling elites in the PRI.
"He's been imposed on us by powerful interests like the TV stations and old presidents," said Javier Aguilar, 62, a biochemist. "How can it be that a country this miserable is home to the world's richest man?" he said, referring to tycoon Carlos Slim.
Created after the turmoil of the Mexican Revolution, the PRI laid the foundations for modern Mexico. It started out as a socialist party that nationalized the oil industry in the 1930s before drifting to the center to establish a corporatist model of rule once described as the "perfect dictatorship."
But Mexicans tired of rampant corruption, rigged elections and heavy-handed rule under the PRI, and finally voted it out of power at the turn of the century.
The PAN took over under former Coca-Cola executive Vicente Fox, promising strong growth and more democratic government. But the economy underperformed its peers in Latin America for most of the 12-year rule by the PAN, which never had a majority in Congress and was unable to push through many reform plans.
When Mr. Calderon succeeded Fox in 2006, he deployed the army against warring drug gangs. Instead of quelling the violence, it soared to new heights and the relentless wave of beheadings and massacres turned even more voters away from the PAN.
Bit by bit, the PRI began to recover ground and Mr. Pena Nieto vowed to stamp out the undemocratic excesses, misuse of public funds and shady acts of political patronage that tarnished the PRI's decades in power.
Yet analysts say he will be challenged to keep the PRI clean, even if he is not already compromised by the deals he had to make to win the support of party barons.
Wary of becoming bogged down in a drug war that has dominated Calderon's presidency, Pena Nieto says he will put more emphasis on reducing violent crime than on targeting drug barons.
"The fight against crime will continue, yes, with a new strategy to reduce violence and above all protect the lives of all Mexicans," Mr. Pena Nieto said on Sunday night.
However, he dismissed accusations by opponents that the PRI might try to make cut deals with the cartels. "Let it be very clear: There will be no deal, no truce with organized crime."