Slovenia was a key transit point during the European refugee crisis with about half a million passing through in 2015.

The anti-immigrant SDS party of veteran right-wing leader Janez Jansa won Slovenia’s parliamentary election, but now faces a difficult task in courting a coalition partner to govern.

The centre-right Slovenian Democratic Party secured 25 percent of the vote, the State Election Commission said late on Sunday.

The anti-establishment LMS party of comedian-turned-politician Marjan Sarec had 12 percent, followed by the centre-left Social Democrats with 10 percent, and the SMC party of outgoing Prime Minister Miro Cerar at 9 percent.

The results mean a coalition government will have to be formed because no party achieved a majority.

In a statement after polls closed, Jansa, 59, said he was committed to forming a government “for the good of all our citizens” and to ensure a “safe Slovenia”.

Sarec said he also expects to be in position to form the government and is ruling out a coalition with Jansa. Most parties said before the vote they were unlikely to join an SDS-led government because of its harsh stance towards migrants.

Crossing ‘all red lines’

Speaking to the POP TV station after polls closed, Sarec said he was “very happy” with the preliminary results, hinting it could give him the opportunity to band with other parties to keep Jansa out of power.

During the campaign Sarec said Jansa’s anti-immigration rhetoric “crossed all the red lines”.

Jansa – a two-time prime minister – was forced to resign five years ago after a corruption scandal but has made a comeback, thanks in part to his strong talk on immigration.

The right-wing leader, who formed a close partnership with populist Hungarian leader Viktor Orban, has vowed to defend the “Schengen border of Europe”.

Slovenia was a key transit route for migrants and refugees trying to reach northern European states during the European refugee crisis of 2015.

Most were fleeing war and poverty in the Middle East, Africa, and South Asia.

No single party is expected to pick up a majority in Sunday’s election and other parties have promised not to work with Jansa if there is no outright winner.

‘Easy stance’

Balkan analyst, Klisman Murati, told Al Jazeera that rhetoric on immigration was being used to distract from economic issues.

“It’s an easy stance to take if you tell the people immigration is the main issue and that’s why your country is not prospering,” he said.

“It’s worked to an extent in the US, it’s worked as a start-up movement in France with Marine Le Pen, It’s taken popularity in other EU countries.”

Far-right and anti-immigration parties have made massive gains across Europe in recent years.

Anti-immigration parties have won elections in Italy, Poland, and Hungary, and are part of a coalition government in Austria.

Prime Minister Miro Cerar resigned in March after the Supreme Court ruled to annul a September 2017 referendum vote in support of a one billion euro ($1.17bn) railway project.

Slovenia, once part of the former Yugoslavia, joined the EU in 2004. It has used the euro as its official currency since 2007.