WARSAW, POLAND -- Polish President Andrzej Duda declared victory Monday in a runoff election in which he narrowly won a second five-year term, acknowledging the campaign he ran was often too harsh as he appealed for unity and forgiveness.

The close race followed a bitter campaign between Duda and Warsaw Mayor Rafal Trzaskowski that was dominated by cultural issues. The government, state media and the influential Roman Catholic Church all mobilized in support of Duda and sought to stoke anti-Semitism, homophobia and xenophobia in order to shore up conservative support.

Duda celebrated what was seen as a mandate for him and the right-wing ruling party that backs him, Law and Justice, to continue on a path that has reduced poverty but raised concerns that democracy is under threat.

鈥淚t was a very sharp campaign, probably too sharp at times,鈥 Duda told supporters in Odrzywol, a town near Warsaw. 鈥淚f anyone is offended by my words, please forgive me. And give me the chance to improve in the next five years.鈥

Duda received 51.03% of Sunday's vote, while Trzaskowski got 48.97%, according to final results Monday from the state electoral commission.

Duda told supporters in Odrzywol that he was grateful and moved by winning the support of more than 10 million voters. He said that with the race now over, it was time to turn to the difficult job of returning the country to strong growth after the economic blow of the coronavirus.

Trzaskowski conceded defeat and congratulated Duda. He thanked his supporters and said his strong showing would be the catalyst to fight to keep Poland from becoming a one-party state.

鈥淭his is just the beginning of the road,鈥 Trzaskowski said.

But Adam Michnik, a prominent anti-communist dissident and the founding editor of the liberal Polish newspaper Gazeta Wyborcza, said the result bodes badly for Poland's young democracy.

鈥淎ndrzej Duda's victory will be understood by his voters, and first of all by those in power, as a permission for the kind of politics that Law and Justice has been pursuing for almost five years, and that is a policy of the destruction of the democratic system, of isolating Poland in Europe, of homophobia, of xenophobia, nationalism and of using the Catholic Church as a tool,鈥 Michnik said.

鈥淚 would not even rule out a situation in which, if this policy is continued and we see an attempt on the free media, culture and science, there could be another `Maidan,鈥' he said, referring to the bloody 2014 pro-Europe protests in Ukraine.

Critics and human rights groups worry Duda's victory will boost illiberal tendencies at home and in the European Union, which has also struggled to halt an erosion of rule of law in Hungary under Prime Minister Viktor Orban.

Among those who welcomed Duda's victory were Orban, as well as the Czech leaders.

Orban congratulated him on Facebook, saying 鈥渂ravo!鈥 while Czech President Milos Zeman though a spokesman said: 鈥淟ong live Poland!鈥

The result was dispiriting for liberals in Europe who are keen to halt what they consider the threat of populism and nationalism.

Remigijus Simasius, the liberal mayor of the Lithuanian capital of Vilnius, offered his condolences to Poles and said the small difference in support of about 2% 鈥渟ometimes determines the path between progress and regress.鈥

Duda got help from U.S. President Donald Trump, who invited him to the White House in late June and said he was 鈥渄oing a terrific job.鈥

His campaign focused on defending traditional family values in the predominantly Catholic nation of 38 million people, and on preserving social spending policies.

The party's popular policies included lowering the retirement age and paying monthly cash bonuses of 500 zlotys ($125) per child to all families irrespective of income.

Many credit Law and Justice for being the first party to reduce the economic inequality that came with Poland's transition from communism to a market economy three decades ago. There is a strong sense among Poles that the economic help is restoring a sense of dignity after decades of hardship from war, communism and the upheaval brought by capitalism.

The party also stoked conflict with the EU by taking control of the top courts and judicial bodies. Officials in Brussels repeatedly expressed concern over the rule of law in both Poland and Hungary, which were for many years hailed as the most successful democracies to emerge from behind the Iron Curtain.

Law and Justice officials have said they plan to continue reshaping the justice system and also want to nationalize foreign-owned private media outlets. Critics fear that lower courts will face increased political pressure and that press freedom will face new threats.

Zselyke Csaky, an expert on central Europe with the human rights group Freedom House, said Duda's victory gives the party 鈥渆ssentially free rein鈥 until parliamentary elections in 2023 鈥渢o do away with limits on its power and work towards destroying Poland's independent institutions.鈥

Sunday's vote was originally planned for May but was delayed by the coronavirus pandemic. Turnout was 68.18%, close to a record set in 1995, in a sign of the huge stakes for Poles.

As the race tightened, Duda turned further to the right in search of votes. He denounced the LGBT rights movement as an 鈥渋deology鈥 worse than communism.

His campaign also cast Trzaskowski as someone who would sell out Polish interests to Jewish interests, tapping old anti-Semitic tropes in a country that was home to Europe's largest Jewish community before it was decimated by Germany in the Holocaust.

The Organization for Security and Cooperation in Europe, which monitored the election, said that while well organized, 鈥渘egative campaigning and mutual vilification abounded鈥 and that 鈥渢he incumbent's campaign and coverage by the public broadcaster were marked by homophobic, xenophobic and anti-Semitic rhetoric.鈥

But the World Jewish Congress focused on Duda's past condemnations of anti-Semitism in a congratulatory statement, not mentioning the harsh campaign.

鈥淧resident Duda has spoken out against this hatred, and we remain hopeful that he will continue to do so,鈥 WJC President Ronald Lauder said.

During the campaign, Duda also lashed out at a German correspondent and a partly German-owned tabloid for their campaign coverage, alleging 鈥渁 German attack in these elections.鈥 A German Foreign Ministry spokesman said Monday that Berlin works 鈥渙utstandingly鈥 with the Polish government and would continue to do so.

------

Associated Press writers Geir Moulson in Berlin; Pablo Gorondi in Budapest, Hungary; and Karel Janicek in Prague and Liudas Dapkus in Vilnius, Lithuania, contributed.