Leading up to the runoff, Mr. Sarec, 39, had narrowed Mr. Pahor’s lead in the opinion polls, an indication that Slovenian voters were in sync with those across Europe, where candidates campaigning from the fringe of traditional political parties and the governing elites have steadily gained support.
The presidential election was considered a dress rehearsal for next year’s voting for Parliament.
While there is a populist tilt in Slovenia, the shift is nowhere near the seismic changes in Britain, where voters last year backed leaving the European Union; in Germany, where the Alternative for Germany became the first far-right party to enter Parliament in decades after elections in October; or in Austria, where the People’s Party emerged in October as the strongest political force in the country, setting the course for a rightward shift.
Both candidates in Slovenia have run as independents, but Mr. Pahor is deeply entrenched in the traditional party system of the left that has ridden the waves of European social democracy since the collapse of Communism. He had served as the country’s prime minister and the president of its Parliament before being elected president in 2012.
Among Slovenians, Mr. Sarec, who was elected mayor of Kamnik in 2010, is better known for impersonating politicians on a satirical radio program than for being one himself, Ms. Staric, the news editor, said.
In the past three weeks, however, Mr. Sarec has managed, according to Ms. Staric, to appeal to “ordinary people, the average Joe, who feels left behind in the global economy, searching in vain for leadership figures and politicians with at least stated ambitions to tackle people’s concerns.”
The collapse of the health care system, unemployment among the youth and the economic recovery were among the major issues for voters. While Slovenians say they do not expect the president to solve their problems, they say they hope that the elected candidate will provide moral guidance to the new Parliament next year.
Slovenia is the wealthiest and most socially progressive of the states that have emerged from the collapse of Yugoslavia. In 2004, it was also the first to join the European Union and NATO as the rest the region still reeled from devastating wars and the grip of nationalist rulers.
Yet Slovenia, a country the size of New Jersey, has struggled to find its place in the European Union, with its leaders refusing to partner openly with other Central European countries like Hungary and Poland, which are now striving to be one of the 28-member bloc’s core decision-makers, like Germany and France.
During the campaign, Mr. Pahor, who had led an American-style campaign using social media to lure voters, insisted that Slovenia belonged to that group of powerful countries. And he frequently dropped the names of Chancellor Angela Merkel of Germany and Jean-Claude Juncker, president of the European Commission, as his “friends” and “allies.”
While Mr. Sarec has emphasized his pro-European Union stance, he has also promised to address Slovenians’ concerns about the European Union’s failure to craft a unified position on immigration or to find solutions to economic malaise in the eurozone.
Slovenia has yet to recover from an economic downturn in 2009, when its economy has shrunk by 8 percent.
During the campaign, Mr. Sarec said the lack of decision-making in Brussels, and the dearth of ambitious politicians among conservatives and liberals alike, have deeply weakened residents’ faith in the democratic process and state institutions.
During the migration crisis in 2015, Slovenia was a front-line country, with tens of thousands of migrants crossing on their way to seek asylum in Germany and Sweden. Last year, Slovenia’s government was instrumental in closing the so-called Balkan route for migrants, working with Austria to its north and fencing off its border with Croatia to the south to stem the flow.
The presidency in Slovenia’s highest elected office, but it holds no executive powers. The winner will be the commander in chief of the armed forces and will have the power to dissolve Parliament and call early elections.
The fight for control of the government next year will pit the right-wing nationalist Janez Jansa, the former prime minister and the current opposition leader, against Dejan Zidan and his left-of-center social democrats.
According to opinion polls released on Friday, Mr. Pahor was expected to win at least 52 percent of the vote, with Mr. Sarec trailing with around 47 percent.
Both candidates rank very low among voters below age 30, scoring the highest support among voters older than 60, a sign of an aging population in one of Europe’s youngest democracies. About 1.7 million Slovenians were eligible to vote on Sunday, although analysts said they feared that the turnout could be even lower than in the first round three weeks ago, when 43 percent of eligible voters cast ballots.
That means a million voters stayed away on Oct. 22, Ms. Staric said, a sign for political parties to “get their act together” for next year’s general election.