DUBLIN — Ireland's left-wing nationalist Sinn Fein party shattered the country's center-right status quo in the weekend's general election with its strongest-ever performance, throwing Irish politics into uncertainty.

First-preference vote counts showed Sinn Fein ahead of the two mainstream parties that have dominated Irish politics for nearly a century, as young voters embraced the long-marginalized party en masse.

The center-right Fine Gael party of Prime Minister Leo Varadkar suffered humiliating losses. In an embarrassing turn of events, Varadkar was outperformed by the left-wing nationalists in his own constituency, although he kept his seat under Irish electoral rules.

“This is no longer a two-party system,” said Mary Lou McDonald, leader of Sinn Fein, formerly the political wing of the Irish Republican Army.

Vote counting continued into Monday, but no party appeared to have an easy path to forming a majority government. If none achieves a breakthrough, a second election could be needed.

McDonald indicated that she would seek first to form a government with smaller parties. The leader of the center-right Fianna Fail party, Micheál Martin, said there was “an obligation on all” to ensure the formation of a functioning government.

Martin did not explicitly address the key question, however, of whether such a government could include Sinn Fein. At least one of his party’s members of Parliament pondered that possibility Sunday.

Ahead of the election, Martin and Varadkar both insisted they were not inclined to govern with the left-wing nationalists.

For the two center-right parties, Sinn Fein’s historical association with the IRA still weighs heavily. The IRA, loyalist paramilitaries and British troops killed about 3,600 people during the long conflict known as the Troubles, which centered on the IRA’s campaign from the 1960s until the late 1990s to force an end to British rule in Northern Ireland.

In an effort to move the party on from its controversial roots, McDonald, 50, framed herself as a progressive, urban leader. Her policies and her rise in politics after a childhood in a middle-class suburb of Dublin appeared to resonate with voters.

As her supporters waited for McDonald to arrive at a Dublin tally center on Sunday afternoon, they enthusiastically chanted, “Hello Mary Lou” — the 1961 song recorded by Ricky Nelson.

Her Sinn Fein party campaigned on a mix of nationalist proposals — including a reunification referendum — and left-wing positions, such as higher taxation of global corporations, a boost in public spending and residential rent freezes.

“Whereas the government would say the economy is doing well, a lot of people feel they haven’t achieved benefit from it,” said Irish News columnist and political commentator Deaglán de Bréadún. “Virtually everywhere you go in Dublin, for example, you will pass a location where someone is sleeping in a tent.”

In the center of Dublin, voters on Sunday echoed that sentiment.

Michael Doyle, 52, said he once supported Varadkar’s center-right party but voted for Sinn Fein for the first time Saturday.

“Homelessness and crime are a big thing, and the two big parties are not helping with that,” he said.

Kevin Burns, a 26-year-old Sinn Fein youth wing activist, said the party “spoke to the issues that are affecting everybody in this country.”

“The housing crisis and the health-care crisis, these things didn’t fall from the sky,” he said.

If Sinn Fein were to be included in a coalition in Dublin, it would become the first major party represented in the government of both Northern Ireland, where it is the second-largest party, and the Republic of Ireland.

The rapid gains in support for Sinn Fein appeared to have caught the party itself by surprise. After weak results in local elections last year, the party fielded 42 candidates — only about half as many as Fine Gael and Fianna Fail each put forward, and probably fewer than needed to fully capitalize on Saturday’s results. The threshold to form a majority government is 80 seats.

Varadkar never commanded such a majority. He was able to govern only because his center-right competitor Fianna Fail had entered into a loose deal to keep the government in power in 2016.

Still, his international profile had steadily risen since he became premier in 2017 as the youngest-ever Irish leader, at 38.

The trained doctor backed grass-roots campaigns that pushed through the legalization of same-sex marriage and abortions, navigated difficult Brexit negotiations with the European Union and Britain and oversaw a phase of economic recovery.

In other E.U. capitals, Ireland was increasingly seen as a new liberal role model in recent years — with the gay and dual-heritage Varadkar as its poster boy.

After months of falling approval, however, Saturday’s vote could spell the end of Varadkar’s ambitions.

Noack reported from Dresden, Germany.