With 99.97 percent of ballots counted, Poland's national election commission says Duda has won 51.21 percent of the vote, with his liberal rival Rafal Trzaskowski bagging 48.79 percent.
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.
With 99.97 percent of ballots counted, the national election commission said on Monday Duda had won 51.21 percent against 48.79 percent for his liberal europhile rival Rafal Trzaskowski.
Duda is allied with the governing 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 serves 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.
A liberal Warsaw mayor
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.
Cultivating a pro-government media
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.
Record-high voter turnout
Duda said the turnout was nearly 70 percent, which would be a record high for a presidential election in the 30 years since Poland threw off communism, embraced democracy, and later gained membership in NATO and the EU.
If confirmed, the high turnout is a sign of the great importance that many Poles placed on Sunday’s vote.
Duda thanked his supporters on Sunday and called the high turnout "a beautiful testimony of our democracy."
To those supporting Trzaskowski, it was possibly a last chance to halt an erosion of the rule of law under Duda and the ruling party, both in power since 2015.
At an election night event, Trzaskowski said he still believed the numbers could turn in his favour.
He did not say why, but the exit poll does not reflect the votes cast from abroad, and a majority of them were expected to go to Trzaskowski.
"All the votes just need to be counted which, in truth, will make this evening a nerve-wracking one for everyone in Poland," Trzaskowski said.
"But I am absolutely convinced when we count each vote, we will be victorious and we will definitely win.”
Long, snaking queues formed at polling stations as social distancing measures were used to stem infections.
Voters also had to wear masks, use hand sanitisers and their own pens, plus give priority to pensioners, pregnant women, and voters with children.
The election had been due to be held in May but was delayed because of the pandemic.
Duda's support has slipped considerably since then, partly because of the virus fallout, which is pushing Poland into its first recession since communism fell.