WASHINGTON — Nonviolent drug offenders could be eligible for shorter prison sentences under legislation approved by a Senate panel Thursday, as Congress took initial steps to change the nation’s criminal justice system.

On a vote of 15-5, the Judiciary Committee approved a bill to give judges discretion to give lesser sentences than federal mandatory minimums in some cases.

The measure would eliminate mandatory life sentences for three-time, nonviolent drug offenders, reducing minimum sentences for those offenders to 25 years. It also would create programs to help prisoners successfully re-enter society.

In a rare display of bipartisanship, the legislation is backed by Senate Judiciary Committee Chairman Charles Grassley, R-Iowa, and the senior Democrat on the panel, Vermont Sen. Patrick Leahy. Texas Sen. John Cornyn, the No. 2 Republican in the Senate, and Illinois Sen. Dick Durbin, the No. 2 Democrat, are also supporters.

The legislation also has the backing of the Obama administration and former Attorney General Michael Mukasey, who served under President George W. Bush.

The aims of the bill are to make the sentencing system fairer, reduce recidivism and contain rising prison costs.

The federal prison population has exploded since 1980, in part because of mandatory minimum sentences for nonviolent drug offenders.

“It’s the just and moral thing to do,” Grassley said. “Inmates will be able to return to society earlier and become productive, law-abiding citizens.”

President Obama praised the legislation Thursday at an event on criminal justice issues at the White House. He said the time has come to make changes.

Disparate voices – from Obama and the American Civil Liberties Union to the conservative Koch Industries – have agreed the current system is broken. In 1980, the federal prison population was less than 25,000. Today, it is more than 200,000.

At the same time, national attention has focused on how police and the criminal justice system treat minorities after several high-profile deaths of black men at the hands of police in several states, including Missouri and Maryland.

The bill is a compromise. While some of the Democrats wanted to eliminate mandatory minimums, Republicans like Grassley were concerned that reducing them could let dangerous criminals go free. Partly to placate some of those conservatives, the Senate legislation would create new mandatory minimums for some charges related to domestic violence and terrorism.

Under the bill, some current inmates could get their sentences reduced by as much as 25 percent by taking part in rehabilitation programs, if they are deemed a low risk to offend again.

The measure also limits solitary confinement for juveniles in federal custody and allows nonviolent offenders older than 60, terminally ill offenders and those in nursing homes who have already served much of their sentences to be released from prison.