Poland's state electoral commission says conservative president Andrzej Duda has won 51.21 per cent of the vote with almost all ballots counted from the country's weekend election.
The nearly-complete results, based on a count of 99.97 per cent of votes counted, shows liberal Warsaw mayor Rafal Trzaskowski has been defeated, attracting 48.79 per cent of the vote.
The final results might vary slightly.
If the result is born out, it would be one of closest elections in Poland's history, reflecting the deep divisions in the European Union nation.
Sunday's vote was originally planned for May but was delayed amid bitter political wrangling.
It follows a bitter campaign dominated by issues of culture in which the government, state media and the influential Catholic church all mobilised in support of Duda, a social conservative.
Duda, backed by the ruling right-wing Law and Justice Party, campaigned on traditional values and social spending in this mostly Catholic nation as he sought a second five-year term.
As the race became tighter in recent weeks, Duda turned further to the right in search of votes. He seized on gay rights as a key theme, denouncing the LGBT rights movement as an "ideology" worse than communism.
Duda's campaign also cast Trzaskowski as someone who would sell out Polish families to Jewish interests, tapping into old anti-Semitic tropes in a country which was home to Europe's largest Jewish community before it was decimated by Germany in the Holocaust.
Australian Associated Press