The Maryland Senate in session on March 22 in Annapolis. (Jonathan Newton/The Washington Post)

A sweeping criminal justice bill that cleared the Maryland Senate last week is supposed to right some of the wrongs of the decades-long war on drugs.

The legislation aims to reduce Maryland’s prison population and save hundreds of millions of dollars on prison costs by easing sentencing laws for nonviolent drug offenders and pushing people who are arrested with drugs into treatment instead of behind bars.

But the bill was almost derailed last week after the Senate Judicial Proceedings Committee amended the measure, arguing that it went too far in keeping offenders out of jail and could pose a risk to public safety. Now the bill heads to the more liberal House of Delegates, where an emotional debate is expected this week.

Senate Judicial Proceedings Committee chairman Robert A. Zirkin (D-Baltimore County) defended the amendments on the Senate floor last week by rattling off a list of violent criminals who, without the changes, would have been eligible for automatic parole or for shorter sentences after probation violations.

That brought a sharp rebuke from Sen. Dolores G. Kelly (D-Baltimore County), one of many African American lawmakers who say the amended bill does not do enough to free those who are trying to rehabilitate their lives and deserve a second chance.

“Nobody in here wants violent people on the street, but the judge is going to consider violence when he sentences initially,” Kelly said during the floor debate. “To scare us all to death with situations that aren’t the norm . . . is not helpful. . . . In spite of all the hard work you did, not all of it was smart. I hope that in a conference committee or somewhere, we come back toward the middle.”

The Justice Reinvestment Act would:

●Send people convicted of drug possession for treatment rather than to prison.

●Eliminate sentencing disparities that have resulted in thousands of mostly African American men serving long sentences for crack cocaine convictions while others, mainly white, received less time for convictions involving the powder form of the drug.

●Make it easier to have drug-possession convictions expunged.

●Offer drug offenders the same number of credits to reduce their sentences that are given to other nonviolent offenders.

●Allow the 1,700 people who are serving mandatory minimums for drug offenses to appeal their sentences.

The bill is comparable to legislation passed in recent years in nearly a dozen states, including Kentucky and Pennsylvania, as governors and legislatures struggle to cut prison costs and address sentencing disparities and aging prison populations.

Sen. Jamie B. Raskin ­(D-Montgomery), a member of the Judicial Proceedings Committee, compared Maryland’s bill with other major legislation the state has passed in recent years, including the abolition of the death penalty, reforms in mandatory-minimum laws and the enactment of the Second Chance Act, which shields certain nonviolent misdemeanor criminal records from public view, making it easier for ­ex-offenders to find jobs.

“This legislation is the most ambitious and comprehensive of criminal justice reforms that we’ve done,” Raskin said. “It’s a real big ship. . . . You push a little too far to one side, you can tip it over.”

In Maryland, 58 percent of prison admissions in 2014 were for nonviolent offenses. And possession of drugs with the intent to distribute was the No. 1 reason people were sentenced to state prison, according to data compiled for state policymakers by the Pew Charitable Trust.

More than 3,200 people return to prison because of technical violations of their probation, such as failing a drug test or missing an appointment, Pew found. Those individuals remain behind bars, on average, for 13 months, at a cost to the state of $34 million.

The Pew data was part of a year-long effort by a panel of lawmakers, judges, public defenders, prosecutors and advocates to grapple with ways to reduce Maryland’s prison population and costs.

The panel, whose recommendations formed the backbone of the criminal justice reform bill, examined why Maryland has experienced large drops in violent and property crime rates over the past decade but only modest changes to the size of its prison population. It concluded that the number of nonviolent offenders serving time has kept the prison population from shrinking significantly, and that it has kept corrections costs at about $1.3 billion a year.

The original bill was projected to reduce Maryland’s prison population from just over 20,000 to about 17,600 over 10 years, saving the state nearly $250 million.

But the Judicial Proceedings Committee, citing public safety concerns, changed parts of the legislation that would have slashed prison time for all probation violations and allowed automatic parole for nearly all offenders after 25 percent of a sentence is served.

The changes, a Pew analyst said, would reduce the state’s savings to $34 million over 10 years.

That finding prompted advocates, members of the Legislative Black Caucus and other liberal lawmakers to say that the bill had been gutted.

The Senate committee responded by dialing back one of its amendments, so that only probation violators who are considered a risk to public safety could be returned to prison for long periods of time.

Zirkin, the chief architect of the amendments, said Pew’s analysis of the bill’s impact included only “guaranteed” savings and does not factor in the reduction in prison costs that would come if many of the 1,700 inmates serving mandatory minimums in Maryland appeal those sentences and are released.

“This is a huge bill moving forward,” Zirkin said. “If this bill lives or dies based on putting someone who is dangerous back out on the street, then it should die.”

Sen. Richard S. Madaleno Jr. (D-Montgomery) countered that he had hoped that the bill “would put Maryland at the forefront of getting people out of prison, getting people the services they needed and actually coming up with a more humane and a cheaper criminal justice system.”

He said it appeared the bill made a “small step” toward that effort.

Gov. Larry Hogan (R) said in an interview that he likes the amended legislation and is concerned about plans in the House to “try to tack on additional things . . . that could jeopardize the bill.”

In the House, the bill will be considered first by the Judiciary Committee, chaired by longtime Del. Joseph F. Vallario Jr. (D-Prince George’s). If it is approved by that panel, the bill would go to the House floor.

It is not yet clear what changes will be sought by delegates. Last year, some members of the Justice Reinvestment Council sought to repeal mandatory minimums altogether, and that effort could be revived in coming days. (Nearly 90 percent of the people serving mandatory minimum sentences in Maryland are African American).

At a private meeting of the Legislative Black Caucus on Wednesday, Del. Joseline A. ­Peña-Melnyk (D-Prince George’s) could be overheard through a closed door encouraging the ­caucus to take a strong stand on the bill.

“We are 47 black members, and we can make a difference,” she said. “This is an issue that we can make a difference on.”

Members of a Judiciary Committee work group have begun poring over the 90-page bill sent over by the Senate, going line by line to discuss possible changes.

On Monday, they will focus on the probation-revocation caps.