Parliament has voted to force the Government to liberalise access to abortion and allow same-sex marriage in Northern Ireland if devolution is not restored.

Gay marriage is illegal in Northern Ireland, while terminations are only allowed in cases where a woman’s life is at risk or if there is a danger of permanent and serious damage to her mental or physical health.

The changes were passed as part of measures aimed at keeping Northern Ireland public services running, two and a half years after devolved powersharing collapsed.

LGBT rights campaigner John O’Doherty said: “Love wins. Today that message rang out from Westminster.

“Being part of this historic campaign over the last eight years is the most important and affirming thing I have ever done – besides marrying my husband.”

The Rainbow Project director said: “Growing up in Maghera I never thought I would see a time where same sex couples would be, not only accepted, but celebrated in Northern Ireland.

“Today’s important victory is shared with our community, allies and supporters.”

The abortion and equal marriage commitments in the Northern Ireland (Executive Formation) Bill will now become law by October 21 this year, unless the Northern Ireland Executive has been re-established by that date.

The deadline for the new same-sex marriage law to come into force is January 2020, and the date by which full abortion regulations must be implemented is March 2020, with some elements happening sooner.

Abortion will be decriminalised and women currently facing criminal trial will have their prosecutions dropped from October 22 this year.

The issues are areas of significant dispute between the DUP and Sinn Fein, who have struggled for years to reconcile their differences and resurrect the institutions at Stormont.

The DUP and religious leaders believe marriage is between a man and woman and civil partnerships are an option for same-sex couples.

Sinn Fein and a coalition of civic society activists believe the change is an issue of equality and human rights.

Access to abortion is also a major touchstone issue in Northern Ireland, with large numbers of women travelling to Great Britain for terminations, and mass rallies for and against medical provision at home.

Sarah Ewart was forced to travel for an abortion in 2013 despite her pregnancy being given a fatal foetal abnormality diagnosis. She has a case before Belfast High Court.

She said: “It’s an overwhelming relief that we’re finally seeing an end to the abortion law that has caused so many women like me huge amounts of pain.

“We’ve wanted reform and justice for so long, and now we’ve got it.

“We’ve spent years fighting alongside Amnesty through the courts and at Westminster, and finally our calls have been answered.

“Finally, we will have the space and dignity in law to make private healthcare choices.”

Amnesty International Northern Ireland director Patrick Corrigan said it was a historic day for human rights.

“Nowhere on these islands have people had to fight longer and harder for their human rights than in Northern Ireland.

“Future generations in Northern Ireland will no longer have to suffer inequality in the way so many have had to endure in the past.

“Now, Amnesty’s attention will focus on ensuring the speedy implementation of access to healthcare and marriage for people in Northern Ireland.”