WARSAW — Poland’s presidential election, widely viewed as the most important since the end of Communist rule in 1989, failed to produce a clear winner on Sunday night, with exit polls showing President Andrzej Duda holding a thin lead over the challenger, Rafal Trzaskowski.
Mr. Duda, a conservative nationalist, had 50.8 percent of the vote in the exit polls to 49.2 percent for Mr. Trzaskowski, the liberal mayor of Warsaw, and neither candidate conceded the race. That set the stage for an extended fight over the results of Europe’s first presidential election since the coronavirus swept across the continent.
The pandemic forced the government to reluctantly move the date of the election from May, giving time for Mr. Trzaskowski to enter the race. In the first round in June, no candidate emerged with more than 50 percent of the vote, setting up a runoff between the top two finishers.
Over the last two weeks, an already bitter contest turned even darker, as Mr. Duda’s campaign leaned heavily on stoking fear of gay people and the free press, and began making arguments tinged with anti-Semitism.
The government has until Tuesday night to declare a winner. A close race will involve counting both in-person and mail-in votes, as well as record numbers of voters registered abroad. The turnout appears to have been the highest since the first, partially free elections were held in the country in 1989.
Despite the uncertainty, Mr. Duda rushed to claim victory.
“It is a privilege to have won with a 70 percent turnout,” he said to supporters in the town of Pultusk, about 40 miles from Warsaw.
But even as he spoke, Polish television was showing people still in line to vote in several locations.
Mr. Trzaskowski sounded equally confident that he would emerge the winner.
“We said it would be close and it is close,” he told supporters in Warsaw. “But I am absolutely convinced that we are going to win. It is just about counting the votes. I am sure that when we count the votes one by one, we will win for sure.”
Mr. Duda’s re-election would ensure that the governing Law and Justice party, which also controls the Parliament, would be able to continue to reshape the nation in ways that critics contend undermine open political debate and the rule of law. The government has corralled independent courts and media, clashing with the European Union, which has accused Poland of damaging democratic values and institutions.
Mr. Trzaskowski had cast the election as a fight for the soul of the nation, to end a government that uses state media for propaganda, silences opposing voices, uses fear and division to build support and antagonizes Europe. He said he wanted to live in a country where “an open hand wins against a clenched fist.”
Last week, the government accused Germany of fomenting discord through media outlets widely viewed as independent but owned by German companies. Mr. Duda’s allies even accused Mr. Trzaskowski of supporting pedophilia and suggested that Mr. Trzaskowski would be controlled by Jewish interests — a fraught topic in a country that was at the epicenter of the Holocaust.
Jaroslaw Kaczynski, the chairman of Law and Justice and the most powerful politician in Poland, accused Mr. Trzaskowski of not having a “Polish soul” or “Polish heart,” for saying that restitution of Jewish property lost during World War II was up for discussion.
“All of us in Poland have Polish hearts and Polish souls and we will not allow ourselves to be divided,” Mr. Trzaskowski said in response, adding that Mr. Duda needed to divide Poles to secure support.
“We will not allow ourselves to be attacked and we will say it loud and clear,” he said. “We’ve had enough of hatred.”
The main target of Mr. Duda’s campaign has been the L.G.B.T. community, the focus of attacks by leading government figures for more than a year now. Last week, Mr. Duda signed a draft amendment to the constitution that would explicitly ban gay adoption, justifying it with the “well-being and security” of children.
Mr. Kaczynski, has called the gay rights movement a foreign import that threatens the nation’s identity. In conservative areas, town councils have been declaring their municipalities “L.G.B.T. free.”
As mayor of Warsaw, Mr. Trzaskowski pushed back.
He issued a rights declaration setting out the city’s commitment to try to help find shelter for gay youths rejected by their parents. He also promised to incorporate World Health Organization guidelines on sex and tolerance education into Warsaw’s school system.
Last year, when Pride marchers faced violence from far-right groups across the country, he joined a parade in Warsaw.
Mr. Trzaskowski has vowed to keep generous social programs created by Law and Justice, making them a less potent campaign issue.
Instead, the contest was fought over cultural issues and Poland’s place both in Europe and the world.
Mr. Trzaskowski has promised to repair the rifts with the European Union, whereas Mr. Duda has touted his close relationship with the Trump administration while attacking the bloc.
The incumbent received a boost recently from President Trump, who met with him at the White House and all but endorsed Mr. Duda, saying: “He’s doing a terrific job. The people of Poland think the world of him.”