Poles were voting on Sunday in a knife-edge presidential election that has highlighted the country’s deep political divisions and may shape its future relations with the European Union.

Incumbent Andrzej Duda, an ally of the ruling nationalists Law and Justice (Prawo i Sprawiedliwość or PiS) party, takes on liberal Warsaw Mayor Rafal Trzaskowski after a campaign that has shown sharply contrasting visions for the future.

Duda’s re-election is crucial if PiS is to deepen judicial reforms that the European Union has criticised as increasing political control over the courts.

The president holds the power of veto and Trzaskowski, who has said he is seeking a more open Poland, has promised that if he wins he will block legislation that he believes would undermine democratic norms.

“(This election) is important because it will be crucial for the next 30 years in Poland,” said Przemyslaw Bochenski, a 60-year-old doctor, at a polling station in northern Warsaw.

“If we do not take the right direction now I am afraid that Polish democracy and Poland, everything we have built, will collapse.”

Given that Poland’s president holds few executive powers, it is unlikely Trzaskowski could bring about significant change if he won. But with the presidency as well as the upper house of parliament in opposition hands, PiS’s ability to implement its agenda would be hampered.

Polling stations in the election, a run-off after a first round on June 28, close at 1900 GMT, at which point the results of an exit poll will be announced.

Duda has painted himself as a defender of Poland’s Catholic values and the generous social benefit programmes that have transformed life for many, especially in the poorer rural regions of the country, the EU’s largest post-communist member.

“I believe we can build the Poland we dream of, a fair Poland, a rich Poland, a strong Poland, a Poland that can protect the weak and doesn’t have to fear the strong,” he told supporters on Friday.

However, while Duda vows to stand with the weak, critics say his campaign has also drawn on homophobia and anti-Semitism.

He has compared what he calls LGBT “ideology” to Soviet-era communist indoctrination, while state TV, the mouthpiece of the government, has used the sensitive issue of Jewish property restitution to attack Trzaskowski.