By Joanna Plucinska and Marcin Goclowski
WARSAW (Reuters) - Polish President Andrzej Duda has won five more years in power on a socially conservative, religious platform in a closely fought election that makes renewed confrontation with the European Union's executive likely.
Final results from Sunday's presidential election runoff showed Duda, 48, won with 51.03% of the vote, the National Election Commission said.
Liberal Warsaw Mayor Rafal Trzaskowski got 48.97%.
Duda is allied with the ruling nationalist Law and Justice (PiS) party, and his victory reinforces the government's mandate to pursue reforms of the judiciary and media which the European Commission says subvert democratic standards.
"To a large extent, the policy of Brussels, or rather Berlin, had focused on supporting the opposition," PiS lawmaker Arkadiusz Mularczyk told Reuters.
"Polish society is not accepting this."
Duda has painted himself as a guardian of traditional values and the generous PiS welfare programmes that have transformed life for many poorer Poles.
However, he ran an acrimonious campaign laced with homophobic language, attacks on private media and accusations that Trzaskowski serves foreign interests.
Since polls closed, he has struck a more conciliatory tone in the deeply polarised country. "Hold back as much as you can from unnecessary words ... because words can hurt," he told supporters. "Please, help me put Poland back together again."
Trzaskowski, who had said he would repair Poland's relations with Europe and use the presidential veto to block any legislation eroding democratic norms, said he thought the PiS would not change direction.
"Unfortunately, it seems like the other side has not learned lessons," Trzaskowski said. "That is why we hear statements that the process of politicizing the courts will be completed... Unfortunately those in power do not want to reach out their hand to us."
Justice Minister Zbigniew Ziobro suggested on Sunday that the PiS could push on quickly with its ambition to change private media ownership toward outlets more favourable to its policies.
The PiS and EU have been divided on climate change and migration, in addition to democracy issues.
Rifts are likely to be evident this week when EU leaders discuss the bloc's long-term budget, with Brussels facing growing calls for funding to be made conditional on respect for the rule of law.
European Commission President Ursula von der Leyen congratulated Duda on Twitter on Monday.
Hungary, another right-wing nationalist voice in central Europe, swiftly welcomed Duda's re-election.
"The international liberal mainstream once again tried everything but the central European right wing is up 3:0," Hungarian Foreign Minister Peter Szijjarto said on Facebook, referring to recent conservative triumphs in Croatia, which is an EU member state, and Serbia, which is not in the EU.
Trzaskowski had said that, if elected, he would seek a more tolerant Poland and abolish state news channel TVP Info, which critics say gave overt support to Duda.
"The public broadcaster was used as a campaign tool for the incumbent," said Thomas Boserup, head of an assessment mission from European election watchdog the Office for Democratic Institutions and Human Rights (ODIHR). "This is the clearest misuse of public resources we have seen in this election."
To many religious conservatives in predominantly Catholic Poland, Trzaskowski came to represent the threats facing traditional values when he pledged to introduce education about LGBT rights in Warsaw schools.
Many members of the LGBT community fear discrimination under a second Duda term.
"We feel powerless," said Dawid Mycek, 35, a LGBT activist and Youtuber. "This is the first presidential campaign I know, which was based on hate, hate speech and dividing Poles."
(Additional reporting Alicja Ptak and Kacper Pempel; Writing by Justyna Pawlak and Alan Charlish; Editing by Timothy Heritage and Mark Heinrich)