Mauricio Macri, the wealthy Buenos Aires mayor who catapulted to prominence on a wave of discontent over government scandals, a feeble economy and combative nationalism, was elected president of Argentina on Sunday, according to election officials.

By 9:30 p.m., with Macri leading by seven points, Buenos Aires Gov. Daniel Scioli, the ruling party candidate, conceded. The winning margin was narrower, with Macri ultimately garnering 51.4 percent of the vote to his opponent’s 48.6 percent, officials said Monday after more than 98 percent of the votes were tallied.

The stunning opposition victory marks a major shift in Latin American politics, ending a dozen years of leftist rule, first by Nestor Kirchner and then his wife, Cristina Fernández de Kirchner, a tenure marked by increasingly fiery anti-American rhetoric and protectionist policies that isolated Argentina and diminished its influence in the hemisphere.

Macri, a 56-year-old engineer raised in a prominent business family, was given little chance to win before the first round of voting last month, as many assumed Fernández’s Peronist party, with its heavy spending on social welfare programs, had an iron grip on power. But he tapped into the widespread anger about corruption in the ruling party, as well as rampant inflation and anemic growth, with his proposals to reform the state-run economy to attract foreign investment and soothe disputes with the United States and the rest of the world.

Macri's campaign slogan was direct: “Let’s change.”

Even before the results were announced, the atmosphere at his closing event in a convention center in the capital had an air of celebration, with cheering crowds and waiters in bow ties passing out hors d’oeuvres. Macri had been leading in the polls going into Sunday’s vote and by 6 p.m., television stations were calling the race in his favor.

“With your vote, you made the impossible possible,” Macri told the cheering crowd in his victory speech. “Together, we can create the Argentina we dream about.”

Argentines say that a sunny day is a Peronist day. But this warm, blue-skied Sunday with purple jacarandas in bloom turned out to be anything but.

Macri’s victory ends a historic chapter for the political movement led by Kirchner and Fernández, the country’s most influential power couple since their role models and party namesakes, Juan and Eva Perón, half a century earlier. Following the devastating financial crisis that began in 2001, first Kirchner and then Fernández led the country back to economic life after a brutal period of mass poverty and tear-gas-filled protests. Voters on Sunday spoke of how their tenure, for all its flaws, prioritized the poor and stood up against the International Monetary Fund and other symbols of exploitative First World capitalism.

“Even though many people may not like Scioli as a candidate, we know that on the other side there is a candidate that represents Argentina’s right and neoliberalism,” said Rafael Rodriguez, 18, who was volunteering as a poll observer in San Isidro, an upper-middle-class northern suburb of Buenos Aires. “You’re voting for a national project. You either vote for a project that includes the redistribution of riches and the strengthening of national industry, or a project where free market rules the country. I think it’s a clear distinction.”

As Ximena Perez, a 41-year-old housewife and mother of two, put it: “The Kirchners managed to pull us out of that dreadful past, and I want this to continue.”

But public fatigue with Fernández’s tenure had been growing. There was deep frustration about the troubled economy. Fernández relied on state-run economic model — she nationalized the oil company YPF — and painted a rosy picture with economic statistics that were widely distrusted. The vast gap between the two exchange rates, the official rate and the black market one, have led many to believe that Macri will devalue the currency. He has said he won’t curtail social spending or begin a privatization binge.

“Even though they raise our pensions every year, it’s not enough,” said Elisa Perez, 69, a retired math teacher who still gives private lessons to make ends meet. “Lately all prices have gone up so much that I can hardly make it through my pension.”

Fernández also pushed Argentina into the camp of South American leftists who have been harshly anti-American, alongside Bolivia, Ecuador and Venezuela. But that “pink tide,” as some called it, seems to be receding as more centrist or conservative voices are gaining ground across the region. She has been battling U.S. creditors — what the government refers to as “vulture funds” — over debts incurred in the financial crisis more than a decade ago. Lilian Tintori, the wife of jailed Venezuelan opposition leader Leopoldo Lopez, showed up at Macri’s victory celebration.

This year, Fernández was further criticized for her response to the mysterious death of prosecutor Alberto Nisman, who was found slumped in his bathroom just a day before he was scheduled to testify to Argentina’s Congress about Fernández’s role in allegedly conspiring with Iran to cover up Tehran’s involvement in the worst terrorist attack in Argentina’s history. Fernández gave differing accounts of Nisman’s death in rambling speeches and Facebook posts rife with speculation. She was never charged, and the investigation of Nisman’s death has stalled. Macri supporters hope to revive it.

Coming into the race, Scioli had been the clear favorite, but he narrowly won the first round of voting last month. The former powerboat racer, who served in administrations dating to Carlos Menem in the 1990s, branded himself the torchbearer for Fernández’s political movement and calls Macri’s proposals “savage capitalism.”

Scioli’s dejected supporters gathered Sunday afternoon in Plaza de Mayo outside his hotel. One of them was Juan Garcia, a 69-year-old retired hospital worker, who felt embittered that Macri, born into an auto and construction fortune, had a privileged upbringing.

“Macri never knew what sacrifice is,” he said. “Not like us workers. He was born with a silver spoon in his mouth. I worked for 30 years in public hospitals and he did nothing to improve the services there during his eight years as mayor.”

But across the city, and the country, voters responded to Macri’s call for a fresh phase in Argentine history. Coming out of the polling booth in a downtown public school Sunday, Felisa Lastra held up her hands in triumph.

“Let’s change,” she said, echoing his slogan. She is 86, with a husband who is 95, and they have 22 grandchildren to think about, she said.

“My country is destroyed. The quantity of poor people. The amount of robbery by our government,” she said. “I told my husband, ‘Alberto, I hope we don’t die without seeing our country rise again. But we don’t have much opportunity left.’ ”

Francisco J. Dotto, a 37-year-old restaurateur and caterer, said that the national project had veered off course. Standing behind the bar at Pascal, a small restaurant on an upscale block in the Recoleta neighborhood, he discussed the challenges of running a small business, including high taxes and aggressive unions that require a percentage of employees’ incomes.

“If you don’t pay, they come and break your windows. It’s crazy,” he said. “We want to have a normal country. We want to be free.”

Dotto voted for Macri to bring this Peronist “bullying” to an end.

“We’re hoping to have a great change in our country,” he said. “A change we need.”