Lawmakers worked late into the evening Wednesday to craft a delicately-worded compromise on a bill that initially mandated the state would close its last two remaining private prisons.

But the Senate Judiciary Committee pulled it off, passing four amendments to House Bill 1019 and the bill itself, unanimously. It now heads to Senate Appropriations.

The amendments have been in the works for several days, but the breakthrough took place Wednesday night after a nearly two-hour negotiating session mid-hearing. 

RELATED: 650 offenders must be moved from a private Colorado prison set to close in 60 days

RELATED: Colorado Department of Corrections wants to end contract with private-run facility and reopen state prison

One major change affects a study on the impacts of closing private prisons on rural counties; an amendment put that study into the hands of the Department of Local Affairs instead of the Department of Corrections. 

The study has been the subject of controversy for months. In the bill’s original language, the study would look at how to close private prisons, the economic impact on the two rural counties — Bent and Crowley — where the state’s last two private prisons are located, and what it would cost the state to buy the prisons. In the House, Rep. Leslie Herod, D-Denver, agreed to an amendment that said the state would look at "whether" to close private prisons, not "how" to close them. 

> Continue reading this story at Colorado Politics.

> And for a deep dive into the "Politics of Prisons" from Colorado Politics, go here. (Subscribers only)

SUGGESTED VIDEOS | Local stories from 9NEWS