BELFAST — When the clock struck midnight in Northern Ireland early Tuesday, abortion and same-sex marriage became legal, marking a historic shift for this traditionally conservative territory.

The changes were all the more controversial because they were initiated by lawmakers in London.

On Monday, there were demonstrations of celebration and defiance.

“Thousands of women from the North have abortions every year, outside the law in their bedrooms or in England,” said Goretti Horgan, a spokeswoman for the abortion rights group Alliance for Choice. “They will now be able to access normal health care.”

Northern Ireland’s abortion laws had been some of the most restrictive in the world — the procedure was banned in almost all cases except when a woman’s life was at risk.

Women could be imprisoned not only for getting an abortion in the territory but for seeking one. Caregivers, too, could be criminally charged for giving advice on obtaining an abortion.

And so generations of women from Northern Ireland traveled elsewhere for abortions. In more recent times, they illegally purchased pills over the Internet to terminate pregnancies at home, without medical care.

But beginning Tuesday, all prosecutions will be dropped, including a high-profile case against a mother who bought abortion pills for her then-15-year-old daughter.

Free and legal abortion services are expected to be available in Northern Ireland by early next year. Until then, the United Kingdom will cover the expenses of anyone traveling for a procedure, and medical support will be provided to anyone needing it after terminating with pills.

The legislation that took effect early Tuesday also paves the way for same-sex couples to marry, starting in February.

At a news conference Monday in Belfast’s Cathedral Quarter, Shane Sweeney, of Love Equality, said he was looking forward to marrying his partner, Eoin McCabe.

“Today means the world to us,” Sweeney said. “We have not asked for more rights but the same rights of everyone else.” 

He and other advocates seek “the right to have our relationships held in the same regard as our heterosexual counterparts,” he said, “and we have done it through unrelenting, positive, grass-roots activism.”

While campaigners have been active in Northern Ireland, and opinion polls suggest support for both measures, the changes are a direct result of an amendment passed in the British Parliament.

Since 1967, the rest of the United Kingdom has allowed abortions to be performed up to the 24th week of pregnancy. But that had never been extended to Northern Ireland.

After a landslide May 2018 referendum to ease the Republic of Ireland’s constitutional restrictions on abortion, attention shifted to the rights of women in Northern Ireland, where strict abortion laws still applied.

A placard displayed at Dublin Castle emblazoned with the slogan “The North is next” captured the mood. 

The Conservative government in Westminster argued that abortion and same-sex marriage were issues for Northern Ireland’s devolved government to decide. But the Northern Ireland Assembly has not convened in nearly three years amid a stalemate between pro-British unionists and Irish nationalists.

Under building pressure, Parliament in July amended a Northern Ireland bill to decriminalize abortion, liberalize the current law and permit same-sex marriage in the region — if the regional government was not restored by an October deadline.

On Monday, antiabortion unionist politicians convened in the Northern Ireland Assembly’s Stormont chamber but were unsuccessful in an attempt to block the law at the last moment. The move was dismissed by Irish nationalist and other political parties as a “stunt.”

Bernadette Smyth, director of Precious Life, the largest antiabortion group in Northern Ireland, said her organization would now “up the ante” with campaigning and possible legal challenges to the new laws.

She said she believes that “abortion is murder,” and she characterized the law change as the “worst onslaught since the Troubles,” referring to the three decades of conflict in Northern Ireland that claimed more than 3,500 lives. 

“Peace must continue in the womb,” Smyth said. 

On the assembly grounds, while antiabortion campaigners repeated their views that “the unborn must be protected” and “abortion is murder,” Alliance for Choice activists chanted, “Not the church, not the state, women must decide their fate,” and carried placards bearing slogans such as “We love choice” and “Free, safe, legal.”

Former politician Dawn Purvis, an abortion rights advocate, said, “For the first time women in Northern Ireland women will be free to choose if, when and how many children they have, in the care of health-care professionals.”

“That is all women have wanted for a long, long, long time,” she said. “Women died trying to get the vote; women died trying to access abortion care. That is not going to happen anymore.”

William Booth in London contributed to this report.