LONDON — While voters across England embraced Prime Minister Boris Johnson’s Conservative Party, it was a different story in Scotland and Northern Ireland, where Thursday’s electoral earthquake has strained the ties that bind the United Kingdom and increased the risk of its eventual breakup.

In Scotland a constitutional crisis looms after the dominant Scottish National Party made significant gains, winning 48 of 59 seats, and said it would press its demands for a second independence referendum — something that Mr. Johnson has already rejected.

The background in Northern Ireland is more complicated. But for the first time in its history, the territory elected more nationalist members of Parliament, who support reunification with the Republic of Ireland, than unionists, who wish to remain a part of the United Kingdom.

Though the situations are quite different in Scotland and Northern Ireland, the common thread is Brexit, a project supported by English and Welsh voters but opposed by majorities in Scotland and Northern Ireland in the 2016 Brexit referendum.