Andrzej Duda, the Polish president, appealed for national unity after he won a second term in office by a wafer-thin margin in a bitterly contested presidential election.
With 99 per cent of the votes counted by Monday morning, Mr Duda had secured 51.2 per cent of the vote, just over 2 per cent more than his rival, Rafal Trzaskowski, the liberal and centre right mayor of Warsaw.
The campaign had been characterised by competing visions of Poland, with the president, an ally of the governing Law and Justice party, promising stability and to protect Catholic values in a campaign that faced accusations of homophobia and anti-semitism.
In contrast, Mr Trazaskowski wanted a more open and tolerant Poland, and to keep in check some Law and Justice policies that many regard as a threat to the rule of law.
Speaking in the wake of his triumph, Mr Duda called for Poles to set aside their differences.
“It was an emotional campaign, and these emotions were unnecessary,” he said. “I wish we can live peacefully in our country, that people can be kind to each other and that we can shake hands with a neighbour who has different opinions.”
During the campaign, Mr Duda was accused of homophobia and anti-semitism, after he ran on an anti "LGBT ideology" platform and with his backers on state television suggesting his rival would "fulfill Jewish demands".
Although he was defeated, Mr Trzaskowski can take some solace from the closeness of the contest, and for reinvigorating an opposition in Poland that had been accused of being rudderless and offering no distinct alternative to Law and Justice. Earlier in the campaign, Mr Duda was expected to win by a much larger margin.
Mr Trzaskowski said that “no matter what the result we have managed to wake people up and create hope by building a fully civic campaign.”
“Poles have created hope for a smiling and more tolerant Poland where balance and common sense are the most important,” he added.
Despite conciliatory talk from political leaders, Poland still faces unsettled political waters. The closeness of the vote exemplified the broad divisions in the country, and could herald more political conflict, especially if the Polish government seeks to exploit a compliant president and the three years it has before the next general election to press ahead with its overhaul of the Polish state.
Its sweeping changes to the judicial system have already caused deep unease in Poland and in the EU, and just before the election Jaroslaw Kaczynski, the powerful leader of Law and Justice, hinted that the government might try and introduce controls on foreign-owned media, a move that will increase fears of an erosion of democracy.
Guy Verhofstadt, the former Brexit coordinator for the European parliament, Macron ally and federalist, tweeted: " Important that President Duda drops his divisive and populist attacks on minorities & works to unite the Polish people. This means listening to young Poles, who voted massively for a future at the heart of a strong Europe!"
Seb Dance, a former Labour MEP for London, added on Twitter: "A sad day for Poland and for Europe - but even worse for LGBT+ people in Poland who have been the victims of a disgusting scapegoating campaign by Duda. Tough times ahead. LGBT+ Poles need solidarity and love going forward. And a tougher response from EU institutions."
Others congratulated Mr Duda on his victory, with the European Commission's chief spokesman saying its president Ursual von der Leyen would "of course" congratulate the winner once the final result was in.
However, he said he had "absolutely no comment" to make on the campaign itself.
"That is clearly a matter for national authorities, if there are comments to be made or accusations that have been levelled in the context of the election campaign. There are authorities in Poland who are in charge of investigating these, it is not the European Commission's role. "
Piotr Buras and Pawel Zerka, experts in Polish politics from the European Council on Foreign Relations, a pan-European think-tank, warned that Mr Duda’s victory could “lead to a further deterioration in the rule of law in Poland, and pave the way for a complete state capture by Law and Justice.”