A new law that gives immunity from prosecution for most offenses committed during Northern Ireland’s decades of sectarian violence is not compliant with human rights, a judge in Belfast ruled Wednesday.

The British government’s Legacy and Reconciliation Bill, passed in September, stops most prosecutions for alleged killings by militant groups and British soldiers during “the Troubles” — the period in Northern Ireland from the 1960s to the ’90s in which more than 3,500 people died.

The law was widely opposed by people in Northern Ireland and the Irish government. Critics say it shuts down access to justice for victims and survivors.

MOM LOSES DISABILITY CASE AFTER NEWS REPORT SHOWS HER WINNING TREE-THROWING COMPETITION

Ruling in a legal challenge brought by victims and their families, Justice Adrian Colton said the law’s provision for conditional immunity from prosecution breaches the European Convention on Human Rights.

The judge also said the law will not contribute to peace in Northern Ireland.

“There is no evidence that the granting of immunity under the act will in any way contribute to reconciliation in Northern Ireland; indeed the evidence is to the contrary,” he said at Belfast High Court.

However, Colton ruled that a new body set up to probe Troubles killings, to be loosely modeled on South Africa’s post-apartheid Truth and Reconciliation Commission, could carry out human rights-compliant investigations.

Britain’s government said it will consider the ruling carefully but added that it remained “committed” to implementing the legacy bill.

Amnesty International said there were “significant questions” for Britain’s government to answer, and urged officials to repeal the law.

“The core part of this legislation was the immunity from prosecution. That has now been stripped out, struck out from the law. So it’s back to Parliament and back to the U.K. government about what they are going to do next,” said Grainne Teggart of Amnesty.

NORTHERN IRELAND’S NEW FIRST MINISTER SAYS HAMAS WILL BE THOUGHT OF AS ‘FUTURE PARTNER FOR PEACE’: REPORT

In December, the Irish government launched a separate legal case against Britain’s government over the Troubles law at the European Court of Human Rights.

The 1998 Good Friday peace accord largely ended violence in Northern Ireland, and British authorities say the law will allow the country to move on.

But those who lost loved ones have said the law would airbrush the past and allow killers to get away with murder. Dozens of legacy inquests have yet to be heard.

Martina Dillon, who was among those who brought the case, said she will “fight until I get truth and justice.” Her husband, Seamus, was shot dead in 1997.

Ongoing lawsuits include a case brought against former Sinn Fein leader Gerry Adams by three people who were wounded in bombings attributed to the Irish Republican Army more than 50 years ago.

The case is likely to be one of the last court efforts by victims seeking justice.