After leading in the polls for months, Javier Milei, a far-right libertarian economist, tumbled to second place in Argentina’s presidential election on Sunday, sending him to a runoff next month that will be an important test of strength for the global far-right movement.

Mr. Milei, 53, will face off against Sergio Massa, 51, Argentina’s center-left economy minister who finished a surprise first Sunday and who will now try to persuade voters he can save the nation of 46 million from the economic turmoil that his government helped create.

Mr. Massa earned 36.6 percent of the vote, to Mr. Milei’s 30 percent, with 98 percent of the votes counted. Candidates needed to surpass 45 percent, or 40 percent with a 10-point margin of victory, to avoid a runoff.

Since winning the primary election in August, Mr. Milei had been leading most polls, with Mr. Massa in second. But many voters on Sunday showed that they preferred a more familiar candidate — Mr. Massa has spent more than two decades in Argentine politics — to Mr. Milei, who has spent his career as a corporate economist and then television pundit.

“For Milei, this should be a shock,” said Ignacio Labaqui, an Argentine political analyst. Mr. Milei received nearly the same percentage of the vote as in the primary election, while Mr. Massa’s support grew after a campaign focused on the dangers of a Milei presidency. “Massa has a very strong chance to become Argentina’s next president,” Mr. Labaqui said.

Mr. Milei has dominated the national conversation in recent months with his brash outsider campaign centered on radical proposals to eliminate the nation’s central bank and replace its currency, the Argentine peso, with the U.S. dollar.

Those plans have gained traction with millions of Argentines as the nation grapples with its worst economic crisis in decades. Poverty is rising, annual inflation is nearing 140 percent and the value of the peso is plummeting. In April 2020, at the start of the pandemic, $1 bought 80 pesos, using an unofficial rate based on the market’s view of the currency. Ahead of the vote, $1 bought 1,200 pesos.

“We are facing a criminal organization that won’t stop committing atrocities to stay in power,” Mr. Milei told supporters on Sunday night, referring to Mr. Massa’s coalition.

Mr. Milei has delivered harsh, often profane attacks against the press, his rivals and foreign leaders, called for looser gun regulations and, in a recent interview with the former Fox News host Tucker Carlson, called climate change part of “the socialist agenda.”

He has also claimed he was the victim of significant voter fraud in the primary elections, though his campaign did not lodge a formal complaint with election officials, and he has backed the false claims that the most recent presidential elections in the United States and Brazil were stolen.

Mr. Massa aimed to paint a contrast to Mr. Milei on Sunday night. “I am not one of those who likes to insult,” he said. “I am one of those who believes in dialogue. I am one of those who believes in consensus.”

A lawyer and longtime politician, with one failed presidential campaign already under his belt, Mr. Massa represents the political establishment that Mr. Milei has made the villain of his campaign. Mr. Massa belongs to the Peronist political movement, which has ruled Argentina for 16 of the last 20 years.

Mr. Massa has built his campaign on a promise of stability to voters, versus the radical change that Mr. Milei is selling.

In a speech to supporters on Sunday night, he pledged a government based on “democratic values, like public education, like independence of powers, like the construction of institutional values that Argentina deserves.”

Yet he has also spent some of the campaign apologizing for his party’s handling of the economy.

While some of Argentina’s recent problems have been worsened by the pandemic and a major drought, Argentine officials for years have run up large deficits to finance free or deeply subsidized universities, health care and energy, as well as to employ a large public sector. To pay for that, they have often printed more pesos, undercutting the currency’s value.

Poverty in Argentina surpassed 40 percent this year, up from 36.5 percent a year prior, while many wealthier Argentines have watched the value of their savings plunge on the global market.

Mr. Massa’s platform includes few major changes to the government’s economic approach, with his main proposal involving increased energy production and lithium extraction.

On Sunday, it appeared that he was able to combine the Peronist party’s fiercely loyal base with more centrist voters worried about Mr. Milei’s ability to govern — a strategy that also could work in the runoff.

“He seemed the least bad,” said Jorge Cernadas, 64, after voting for Mr. Massa in Buenos Aires. “I don’t have a lot of faith in anyone’s economic plan.”

After the results were announced on Sunday night, showing Mr. Massa in first, a gathering outside his election-night headquarters turned into a street party. “I was really scared, but now I’m really relieved,” said Luciana Kerner, 47, an Uber driver.

Mr. Milei’s pool of support is largely made up of young, male voters excited about his combative, anti-establishment rhetoric and older Argentines desperate for change.

“Even if I’m not 100 percent in agreement with a lot of things, he’s the person who is truest to himself,” Gabriel Silbeir, 21, who serves in Argentina’s military, said at a polling station on Sunday.

Polls for months have shown that Mr. Milei would beat Mr. Massa in a runoff, but those same polls proved to be inaccurate on Sunday. A third candidate, Patricia Bullrich, a right-wing former security minister, also appeared to have a shot to reach the runoff, according to polls, but was eliminated on Sunday after receiving just under 24 percent of the vote.

Mr. Milei now must attract nearly all of Ms. Bullrich’s supporters to beat Mr. Massa, Mr. Labaqui said. While Mr. Massa finished first on Sunday, there remains strong anti-Peronist sentiment across the nation after a string of corruption scandals and economic crises.

A Massa presidency would likely lead to few major changes for Argentina, while a Milei presidency could deliver a shock to the nation’s politics and economy.

If elected, Mr. Milei has pledged a drastic free-market overhaul. He wants to lower taxes, slash regulations, privatize state industries, shutter 10 of the 18 federal ministries, shift public education to a voucher-based system and cut federal spending by 15 percent of Argentina’s gross domestic product.

His biggest proposals are to get rid of the Argentine central bank and the Argentine peso, which he says will end inflation.

Yet many economists worry that Mr. Milei’s libertarian economic theories, which have little history of real-world application, could instead inflict even more damage on an already fragile economy, one of Latin America’s largest.

Emmanuel Alvarez Agis, Argentina’s former deputy minister of the economy under a leftist government, said the economic proposals would be a sort of experiment. “And we would be the mouse,” he added. “Forty-six million of us.”

Economists say dollarizing the economy will require a major influx of dollars, but it is not clear where Argentina could get that money. The country is already struggling to pay a $44 billion debt to the International Monetary Fund.

Mr. Milei would also lack many clear allies in Congress, though he has said that he would put the issue to a national referendum.

Mr. Milei has also attracted attention for his eccentric personality. His supporters have nicknamed him “The Wig” for his unruly hairdo (another echo of Mr. Trump) and embraced his love for his five cloned mastiff dogs, four of which are named for conservative economists.

Before the results were announced on Sunday, Mr. Milei’s campaign already complained of reports of voter fraud, saying it had received 4,500 reports of stolen or damaged ballots for Mr. Milei’s party.

After his second-place finish, some of his supporters raised similar allegations. “There was fraud,” Rocio Baier, 35, a systems analyst outside the Milei campaign headquarters in Buenos Aires on Sunday. “Milei did really well in the primary, and now there is a clear difference. It doesn’t make sense.”

Lucía Cholakian Herrera and Natalie Alcoba contributed reporting.