The Massachusetts Supreme Judicial Court issued a unanimous decision Friday meant to reduce the population of the state’s prisons and jails as a second prisoner death was linked to COVID-19.

The state’s top court ruled that inmates who are awaiting trial and are not charged with certain violent, serious offenses can seek release with a presumption that they we will be let go unless they are considered to be an “unreasonable danger” or a flight risk.

The court also urged the state Department of Correction and the Parole Board to expedite parole hearings, and to increase the release of prisoners already approved for parole and those nearing the end of their sentences.

The 45-page ruling was in response to an emergency petition filed last week to reduce the prison population and limit outbreaks of the coronavirus, filed by the Massachusetts Association of Criminal Defense Lawyers, the Committee for Public Counsel Services and the ACLU of Massachusetts.

Matthew Segal, legal director at the ACLU of Massachusetts, praised the decision for providing relief to pretrial detainees but he said it didn’t go far enough.

“It falls short of what is necessary to prevent more illness and death among people in custody, correctional staff members, and the broader community,’’ he said.

On Friday, the state Department of Correction said a second prisoner had died who tested positive for COVID-19. Over the last two weeks, the number of confirmed cases throughout the prison system has steadily risen, reaching 25 inmates and 17 DOC staff and medical providers on Friday.

Judge Frank Gaziano, who wrote the decision for the court, said in the ruling that social distancing in the state’s prisons and jails is “nearly impossible” and sanitation is a challenge. There are hundreds of prisoners with chronic diseases and nearly 1,000 who are over the age of 60, he wrote.

“All parties agree that a significant COVID-19 outbreak in Massachusetts correctional institutions would pose considerable risk to those who are incarcerated, correctional staff and the broader community,” he said in the ruling.