A nationalist candidate backed by U.S. leader Donald Trump won Poland’s presidential election, defeating the centrist mayor of Warsaw in a blow to the country’s pro-European Union government.

Karol Nawrocki, a conservative historian and former boxer, won 50.9%, while Rafal Trzaskowski took 49.1%, according to Bloomberg News calculations based on data from 100% of precincts reported by the electoral commission.

In months of campaigning, the nationalist managed to close what had been a formidable lead by Trzaskowski in polls. The ballot is likely to determine whether one of the EU’s fastest-growing economies and one of NATO’s biggest defense spenders remains a reliable partner within the 27-member bloc, which is under mounting pressure from Trump’s tariffs and Russia’s threat to the east.