THE STATE’S HIGHEST COURT Friday ordered nearly all people held in jails awaiting trial be released on their own recognizance because of the threat of COVID-19 infection.

The unanimous opinion from the Supreme Judicial Court barred releasing anyone held without bail or those charged with violent, sex, or drug trafficking crimes. The court also held that if district attorneys deem someone a threat to flee or a danger to the public, prosecutors would have 48 hours from an inmate’s petition for release to make an argument that he or she should not be released.

The 45-page ruling was a partial victory for those seeking to reduce inmate populations during the COVID-19 pandemic but the court denied a wider request to consider releasing inmates already serving sentences. For those inmates, the court deferred to Department of Correction and Parole Board processes.

“We agree that the situation is urgent and unprecedented, and that a reduction in the number of people who are held in custody is necessary,” Justice Frank Gaziano wrote in the unanimous opinion siding, in part, with the vast array of organizations and attorneys who brought the case seeking emergency relief.

In addition to the release, the SJC ordered the DOC and county sheriffs to file a daily census of the entire inmate population; how many prisoners and staff have tested positive for the virus; how many people are being detained while awaiting trial; and how many are released each day as a result of the order. So far, two inmates have died at the Massachusetts Treatment Center in Bridgewater and another two dozen have tested positive for the novel coronavirus at the state’s correction facilities. About 18 prison staffers have tested positive.

Gaziano based his decision largely on the close quarters inside the state’s prisons and jails that make social distancing recommendations impossible. Statistics accompanying the decision said the state’s prisons and jails are well below inmate capacity. The prisons as a whole are operating at 73 percent of capacity, while jails are operating at 56 percent of capacity.

Officials from the three main organizations that brought the suit – the ACLU of Massachusetts, Committee for Public Counsel Services, and the Massachusetts Association of Criminal Defense Lawyers – were muted in their praise for the decision.

“We are glad that this decision affords some relief for pretrial detainees, as well as important reporting requirements,” Matthew Segal, ACLU of Massachusetts legal director, said in a statement. “But we believe it falls short of what is necessary to prevent more illness and death among people in custody, correctional staff members, and the broader community.”

Jake Wark, a spokesman for the governor’s public safety office, welcomed the decision. “The Administration is pleased with the court’s ruling that individuals serving sentences should not be automatically released back into the community. For those awaiting trial, the Administration believes the question of release should be decided on a case-by-case basis, with the most dangerous individuals remaining in custody,” Wark said in a statement.

The SJC declined to order the early release of vulnerable prisoners who are serving sentences but urged the Department of Correction and the state Parole Board to give serious consideration to expedited release of nonviolent inmates over the age of 60 and others vulnerable to contracting or spreading the virus.

Gaziano noted in his decision that the Parole Board had held hearings and agreed to release scores of inmates who are eligible. That process takes about two weeks to wend its way through the system once the decision is made. He urged officials to speed up the release as the state heads into what is expected to be a surge of COVID-19 cases.

“During normal times, the two-week delay the board states is standard might be reasonable,” he wrote. “But these are not normal times. We urge the board to expedite release of these previously approved individuals, as well as to expedite hearings on other inmates who are eligible for parole.”

Gaziano accepted the separation of powers argument from some district attorneys that only the executive branch has the authority to release prisoners. He noted, however, that prisoners who have been convicted of crimes in the last two months and have a hearing scheduled to revise their sentence could be released by the courts.

“The Court has made clear that the Executive Branch has the authority to address the danger facing all those currently serving sentences, and we urge the Governor to utilize that power to help prevent a potentially deadly outbreak,” Anthony Benedetti, chief counsel for CPCS, said in a statement.

Earlier in the week, Gov. Charlie Baker said he opposed releasing inmates back into the general civilian population, especially if they had no safe place to go.

“This is a very difficult time to be putting people into the community unless you really believe that’s going to be better for them and better for the community,” Baker said.

The plaintiffs brought up potential constitutional issues, such as the Eighth Amendment barring cruel and unusual punishment, but did not make that a focus of their arguments. Gaziano left open the door that those arguments could be brought by inmates in possible future filings, an opening that some say may be too little, too late by the time they come before a judge.

“The SJC invited these prisoners to return to Court if and when the COVID-19 pandemic spreads sufficiently in our prisons and jails to raise Eighth Amendment concerns of ‘cruel and unusual punishment,’” Victoria Kelleher, president of the criminal defense lawyers’ association, said. “Of course, at that point, it will be too late for many prisoners. History will determine whether the SJC’s decision amounts to justice or a tragic missed opportunity to save vulnerable people and a horrible stain on the record of the oldest supreme court in the world.”

Some district attorneys praised the ruling, noting it validated steps many had already taken.

“We started about three weeks ago collaborating with the sheriff” to release pretrial detainees who don’t pose a threat, said Middlesex District Attorney Marian Ryan. “What it reflects today is a balance between the public safety concern and the recognition we’re in pretty unusual times.”

Ryan said her office has agreed to the release of about 81 people since the onset of the coronavirus outbreak and the ruling could affect roughly 120 more currently being held. She said about nine people have tested positive in the county’s jails, mostly staff and civilian workers. She also said the number of arrests in her county are down “about 80 percent” in the last six weeks, which keeps the number of detainees low as well.

Norfolk District Attorney Michael Morrissey said, like Ryan, his office has been releasing low-level defendants for weeks, especially those being held on less than $5,000 bail. But he said the numbers are not that large, saying he has released about 30 so far and only about one-quarter of the estimated 200 or so detainees in the county jail would be impacted by the ruling. He said the remainder either come under the exceptions for violent or sexual crimes or pose a sufficient danger that his office would oppose their release.

Morrissey, though, said the pandemic has led to a noticeable reduction in criminal activity, especially drunken driving, vehicular homicides, and property crimes because people are staying home and police are recognizing the unique situation. He said the downturn in arrests has led to a drop in the population at the house of correction.

“I think they are showing great restraint and common sense – they always do – but especially now recognizing the system is under stress,” he said of local police.