LONDON — Britain's parliament voted on Tuesday in favor of a plan that would compel the government to legalize same-sex marriage and extend abortion rights in Northern Ireland, if the province is unable to re-establish its own devolved government.

The changes passed with a large majority in parliament in London on Tuesday and turned a routine, technical piece of legislation into a vehicle that could enact major social reforms in Northern Ireland.

The province is the only part of the United Kingdom where same-sex marriage is not allowed, and laws there forbid abortion except where a mother's life is at risk.

To the south, once staunchly conservative Ireland legalized same-sex marriage in 2015 and liberalized its abortion laws in a separate referendum last year.

The legislation has several stages to pass before it creates a legal duty on the British government to amend Northern Ireland's laws. That duty only comes into effect if the Northern Irish assembly, which collapsed in 2017, has not been re-established by Oct. 21.

Earlier this year, thousands of people marched through Belfast to demand the recognition of same-sex marriage.

Previous attempts to legislate for same-sex marriage have been blocked by the Democratic Unionist Party (DUP), a key ally of British Prime Minister Theresa May, despite opinion polls in recent years showing most in the region are in favor.

Advocacy groups have called on the government to bypass the frozen local assembly and introduce legislation in the British parliament in Westminster.

Last year, Britain's Supreme Court found Northern Ireland's strict abortion law was incompatible with the European Convention on Human Rights but said it did not have the powers to make a formal declaration that the law should be changed.

Northern Ireland has been without a devolved executive for 2.5 years since Irish nationalists Sinn Fein withdrew from the compulsory power-sharing government with the pro-British DUP.

On-off talks to restore the executive resumed in May after a hiatus of more than a year but have made no obvious progress. Ireland's government said last week key differences remained.

Sinn Fein, which has consistently raised the DUP's stance on same-sex marriage as a major stumbling block in the political talks, said the issue should be addressed by the local assembly but that it was inevitable that the British government's failure to defend "basic rights available everywhere else on the islands would be confronted", as it was by parliament on Tuesday.

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM