CORK, Ireland — Ireland on Saturday bucked the European trend of supporting populist, right-wing groups by spectacularly backing the left-wing, nationalist Sinn Féin party, making them the most popular political party in the country.

The seismic shift could result in a referendum on reunifying the country after 99 years.

While many seats have yet to be filled in Ireland’s complex and labyrinthine electoral system, there's one clear winner from Saturday’s vote.

Sinn Féin won 24.5% of the popular vote, edging out both Fianna Fáil and Fine Gael, the two center-right parties that have ruled Ireland for the better part of a century. The surge toward the nationalist, left-wing party signals a seismic change in the Irish political landscape that mirrors changes across Europe, where hegemonic political groups have been usurped by formerly fringe parties. While most of those have been right-wing movements, such as Fidesz in Hungary and Alternative für Deutschland in Germany, Sinn Féin’s anti-austerity politics closely match those of Spain’s Podemos and Syriza in Greece.

Despite Sinn Féin’s victory, there's no guarantee it will be in power once the dust settles.

Party leader Mary Lou McDonald said Monday morning that she'll be seeking a mandate to govern, and her first preference is to form a left-wing coalition, which she says Irish voters have called for.

But even with all the seats to be filled, there's very little chance that McDonald’s rainbow coalition — which would include the Greens, the Social Democrats, and a wide range of independents — will be able to attain the 80-seat majority needed in the Irish Parliament.

That means she'll likely have to seek a partnership with one of the two historically mainstream parties.

Prior to Saturday’s vote, both incumbent Taoiseach Leo Varadkar, leader of Fine Gael, and Michael Martin, leader of Fianna Fáil, ruled out the possibility of going into government with Sinn Féin.

Both parties expressed concerns about Sinn Féin’s past ties to the Irish Republican Army and its economic policies, which they called anti-business and anti-Europe.

However, within hours of the exit polls being announced on Saturday night, Martin had done a U-turn and said he was open to talking with McDonald about forming a government.

But Varadkar stood firm, ruling out a coalition, and essentially ensuring he would no longer lead the country once the election was over.

“I have consistently said that I will talk to and listen to everybody. I think that is what grown-ups do and that is what democracy demands,” McDonald, who won her seat in Dublin, said after the vote.

She added that it was “not sustainable” for either Varadkar or Martin “to say they will not speak to us, representatives of such a sizable section of the Irish electorate.”

But whoever wants to partner with Sinn Féin will have to agree to hold a referendum on unifying Ireland, a red line McDonald outlined in the lead-up to Saturday’s vote. While McDonald has repeatedly said that “constitutional change is in the air,” the situation is complicated significantly by Brexit. And in Northern Ireland, many will fiercely oppose any effort to unify north and south.

“There's no appetite for a border poll in Northern Ireland — even talking about it is going to add further destabilization” said Steven Aiken, leader of the Ulster Unionist Party, in response to McDonald’s calls.

Sinn Féin’s victory came as something of a surprise to the party itself, given it ran only 42 candidates across the country, half the number put forward by the two main parties. Most experts believe the party could have won a lot more seats if they had just run more candidates.

“The evidence overwhelmingly suggests that if Sinn Féin had run more candidates, the result would have been very different, and in their favor,” Carl Kinsella, a political analyst, said on Twitter.

Sinn Féin’s rise to power in Ireland has been both dramatic and a long time coming. For decades, the party was seen as an outlier that ran on the single policy of trying to unify Ireland.

But the economic crash of 2008 gave it an opportunity to fill the void left by the mainstream parties, who were to blame for crashing the country’s economy.

Sinn Féin became the party of the working class, building up a strong group of local councilors who backed local communities that were fighting for better housing and employment opportunities.

The party further endeared itself to Ireland’s younger generation by backing campaigns to legalize gay marriage and repeal Ireland’s antiquated abortion laws. Finally, the party replaced leader Gerry Adams, a former IRA commander, with McDonald, who has no direct link to the paramilitary activities of the past.

But for all that, Saturday’s vote came as a shock to even the most connected Irish political watchers, especially in the wake of disastrous local elections just over six months ago.

Sinn Féin successfully rode a wave of anger at the government’s inability to solve the housing crisis in Ireland and its management of a creaking health care system — two issues that excited the electorate much more than the successful negotiations over Brexit, which Varadkar had pinned his campaign on.