Updated

For much of the past century, it was hard to get elected to any office in Mexico — even to get a government job — without being a staunch member of the Institutional Revolutionary Party, which held an iron grip on power as administrations came and went.

Now the party itself has turned to an outsider as its candidate for president: Jose Antonio Meade, a longtime technocrat who until recently wasn't even a member of the party.

Weighed down by an unpopular administration due to corruption scandals, rising violence, a sluggish economy and frustration with President Enrique Pena Nieto, the party known as the PRI apparently figured one of its own would be too toxic to voters and a "citizen candidate" would fare better.

In the race to Sunday's election, things haven't quite been turning out that way.

Meade, a 49-year-old five-time Cabinet secretary under governments of different parties, has struggled to escape widespread voter rejection of the PRI, which seems headed for the worst electoral result since it was created by the country's rulers in 1929.

Most polls put him in third place behind leftist front-runner Andres Manuel Lopez Obrador and conservative Ricardo Anaya.

Luis Miguel Perez Juarez, director of the School of Public Policy and Government at the Monterrey Technological university, said the PRI overestimated the chances of Meade, who enjoyed little support among the party stalwarts and was largely unknown to the general public.

"Desiring to maintain power, the PRI made a strategic decision, and although the diagnosis was correct, there was a mistake," Perez said.

Meade's camp has been unflinchingly optimistic, however, touting internal surveys putting him in second and predicting enough undecided voters will swing his way to close the gap.

Perhaps conscious of the charisma gap between himself and Lopez Obrador, Meade recently asked Mexicans to vote with their heads and not their hearts.

"They may promise you the moon, but they cannot deliver it," Meade said. "I will come through for you."

Meade was born in Mexico City with links to both the PRI and its rivals — his father a PRI Cabinet minister and his mother a schoolteacher from a family with roots in Anaya's conservative National Action Party, or PAN. Meade holds a law degree from the National Autonomous University of Mexico and a PhD in economics from Yale, and he has been rubbing elbows with the political elite his whole life.

He was secretary of energy and later the treasury under President Felipe Calderon of the PAN and was the only Cabinet member to remain when Pena Nieto was elected in 2012.

As foreign relations secretary, in 2015 he received then-candidate Donald Trump to Mexico, a visit that caused heavy criticism for Pena Nieto for his perceived bungling of the encounter.

Meade's name was first floated as a possible presidential candidate when he was made secretary of social development, a post traditionally linked to electoral ambitions as it entails touring the country to implement social programs. He later returned to head the Treasury Department in 2016.

Vanessa Rubio, a longtime collaborator, said Meade was never obsessed with the idea of running for president but once nominated left the treasury with hopes of overseeing a transformation of the PRI. She praised him as a skilled team leader who is quick to grasp policy details.

"He keeps track of the chess board in his head with all its variables," Rubio said.

Those close to Meade say in person he is easygoing and personable. However, he has struggled to project in public the same confidence he is said to possess in private.

The candidate has acknowledged that corruption, impunity and violence are serious problems and has proposed measures to confront them — though without criticizing the current administration.

He supports continuing the military's role in the country's war on drug gangs, would maintain a controversial education reform seen as one of Pena Nieto's main accomplishments and vows to boost schools and raise the salaries of "good teachers." Meade has promised more public hospitals and to strengthen social programs.

"What I seek is a transformation of the country ... a government that represents the poor and the rich. I will not let you down," he said.

Meade's main appeal has been to tout his personal honesty and he has released his own financial information to public scrutiny. But a rash of scandals involving other PRI politicians have hampered his campaign, and some media reports have accused him of knowing about cases of corruption and not taking action.

Late in the campaign and seeking to reverse the polls, Meade has changed style, adopting a more folksy manner and even tossing off some mild vulgarity. He has attacked Lopez Obrador's suggestion of an amnesty for some criminals and labeled Anaya a "common thief" due to allegations of graft that have not been proven or even resulted in charges.

"At the beginning he was very technical, and at the end of the day, although it may sound cynical, Mexicans don't want to listen to proposals," Perez said. "They prefer spectacle."

Meade has been successful at garnering headlines with the new approach, but not at moving the polls much. Rubio insists the campaign's numbers put him in second about 10 points behind Lopez Obrador with plenty of undecideds, arguing victory is still within grasp.

Perez said Meade has two reasons to hope for a surprise on election day.

For one, he said polls don't reflect the "hidden or embarrassed vote" — people who lie in surveys, and many of whom would likely go with the PRI.

Also, the party has a massive nationwide electoral machine, often relying on patronage and handouts, that can turn out millions of party militants. Two allied parties, the Greens and the teacher union-based New Alliance, are also known for efficiency in getting sympathizers to the polls. So a low overall turnout could benefit Meade.

But with support for Pena Nieto at historic lows for any president in modern Mexico, it may simply be too tall an order.

A surprise victory by the PRI would likely leave many Mexicans figuring the party had resorted to the same sort of heavy-handed electoral shenanigans it used through most of the 1900s.

"Nobody would believe it," Perez said.