Polish President Andrzej Duda has won five more years in power on a deeply conservative platform after a closely fought election that is likely to deepen the country's isolation in the European Union.
Nearly final results from Sunday's presidential election put him on more than 51%, giving him an unassailable lead over Warsaw mayor Rafal Trzaskowski, who won almost 49% of the votes, the National Election Commission said.
Duda is allied with the ruling nationalist Law and Justice (PiS) party, and his victory will give the government a new mandate to pursue reforms of the judiciary and media which the executive European Commission says subvert democratic standards.
"I don't want to speak on behalf of the campaign staff, but I think that this difference is large enough that we have to accept the result," Grzegorz Schetyna, the former head of the opposition Civic Platform grouping that fielded Trzaskowski.
Backed by PiS, Duda ran an acrimonious campaign, laced with homophobic language, attacks on private media and accusations that Trzaskowski serve foreign interests instead of Poland's. Trzaskowski dismissed the accusations.
Duda's victory opens the way to new clashes between Poland and the European Commission as the EU tries to deal with the economic fallout of the COVID-19 pandemic and rising nationalism across the 27-member bloc.
Before PiS and Duda came to power in 2015, Poland had one of the most pro-European administrations in the bloc's ex-communist east. But it has become increasingly combative, with divisions focusing on climate change and migration, in addition to democratic norms.
Warsaw mayor since 2018, Trzaskowski had said he would seek a more tolerant Poland if elected. He has criticised PiS' rhetoric, vowing to abolish state news channel TVP Info, which critics say gave overt support to Duda in its programming.
But to many religious conservatives in Poland, a predominantly Catholic nation, he came to represent the threats facing traditional values when he pledged to introduce education about LGBT rights in the city's schools.
"It's what populists do very effectively. You name the enemy and you focus on combating him. This is what was used in this campaign, the fear of others," Anna Materska-Sosnowska, a political scientist at the Warsaw University.
In the last week of campaigning, PiS leader Jaroslaw Kaczynski accused Trzaskowski of being at the centre of attempts to allow minorities to "terrorise" the rest of society.
Economic policy was also at the heart of the election, with Duda painting himself as a guardian of generous PiS welfare programmes that have transformed life for many poorer Poles since the party came to power in 2015.
PiS now faces the prospect of three years of uninterrupted rule with the next parliamentary election scheduled for 2023.
Justice Minister Zbigniew Ziobro suggested late on Sunday the party could push on quickly with its conservative agenda following the vote, and with its ambition to spur change in private media ownership towards outlets more favourable to its ambitions.
"We need to take care of the issue of values more than before," he told state broadcaster TVP. "There is also the matter of an imbalance among the media."
Some observers say Trzaskowski's strong showing could energise the opposition, which has struggled until now to formulate a cohesive narrative in the face of the PiS success in winning over many Poles with its economic and social agenda.