LONDON — Northern Ireland is headed for an unwanted early election after its deadlocked lawmakers failed Thursday to break a political impasse triggered by Britain’s exit from the European Union that has shaken the power-sharing structure underpinning the region’s hard-won peace.

Members of the Northern Ireland Assembly met but failed to elect a speaker, the first step toward restoring a government that splits power between Irish nationalists and British unionists, on ice since an election in May.

Attempts to nominate a speaker were blocked by the biggest British unionist body, the Democratic Unionist Party, as part of its protest over post-Brexit customs checks that unionists see as undermining Northern Ireland’s British identity.

Democratic Unionist Party leader Jeffrey Donaldson said his party would not agree to nominate an executive “until decisive action is taken … to remove the barriers to trade within our own country and to restore our place within the United Kingdom internal market.”

The UK government says it will call a new election for the assembly on Friday if a power-sharing government is not in place by a six-month deadline that ends at midnight.

“I have consistently been clear that if the executive is not formed by Oct. 28, I will call an election,” UK Northern Ireland Secretary Chris Heaton-Harris said. “Time is running out, and people in Northern Ireland deserve locally elected decision-makers and an executive who can respond to the issues facing people, families and communities across Northern Ireland during this challenging time.”

The crisis comes at a time of change in Northern Ireland, a part of the United Kingdom with two main communities: Mostly Protestant unionists who consider themselves British and largely Catholic nationalists who see themselves as Irish.

In May’s election, Sinn Fein — which seeks Northern Ireland’s union with Ireland — for the first time became the largest party in the 90-seat assembly, entitling it to fill the post of first minister. The DUP came second.

Sinn Fein’s Northern Ireland leader Michelle O’Neill said voters wanted “grown-up politicians” to grapple with a worsening cost-of-living crisis.

“People need to know that we have their backs,” she said, accusing the DUP of wanting to turn the clock back to “yesterday.”

But DUP assembly member Paul Givan said unionist views were being “disrespected.” He said power-sharing had to operate by “consensus and consent, not contempt.”

Politicians from other parties expressed dismay at the gridlock that is paralyzing politics while people are struggling with soaring food and energy prices.

“It was depressing and shameful,” Matthew O’Toole of the moderate nationalist Social Democratic and Labour Party said. “It’s not just shameful of people to boycott government in the middle of a cost-of-living emergency; it’s a huge and profound strategic error for unionism to allow that chamber to lie empty and silent while people are struggling.”

Northern Ireland is the only part of the UK that shares a border with an EU member — Ireland. When Britain left the bloc in 2020, the two sides agreed to keep the Irish border free of customs posts and other checks because an open border is a key pillar of the peace process that ended decades of violence in Northern Ireland. Instead, there are checks on some goods entering Northern Ireland from the rest of the UK.

That solution has spiraled into a political crisis, with unionist politicians refusing to form a government because they see the checks as undermining their British identity and Northern Ireland’s place in the United Kingdom. While the DUP wants the Brexit protocol scrapped, most other parties in Northern Ireland want to keep it, with tweaks to ease the burden on businesses.

Earlier this year, the UK government of then-Prime Minister Boris Johnson introduced legislation to suspend the checks and rip up part of its legally binding Brexit treaty with the EU. The unilateral move brought legal action from the EU and the risk of an all-out trade war.

After Johnson’s departure last month, the UK refused to drop the treaty-breaching bill, which is going through Parliament. But Britain and the EU have also restarted talks on a negotiated solution, and Sunak’s appointment this week has raised hopes of a thaw in relations.

Sunak spoke Wednesday with European Commission President Ursula von der Leyen in a call that both sides described as positive.