CONCORD — New Hampshire’s “pay-to-stay” prison law could soon become a thing of the past.

The House and Senate have both passed a bill (HB 518) to repeal the statute that allows the state prison system to charge inmates for the costs of incarceration during or after their release.

The bill has widespread nonpartisan support, having passed the House on a voice vote in February and the Senate in a voice vote on Thursday.

It still has to be reviewed by the Senate Finance Committee, given the dollars involved, and will come back to the Senate for another vote, but its passage is virtually assured.

The law allows the Department of Corrections to recover the cost of incarceration for up to six years after the inmate’s release, by petition to Superior Court for a judge’s order.

Sen. Melanie Levesque, D-Nashua, said the statute was used infrequently and on a “seemingly arbitrary” basis.

Corrections gets 59 percent of the money collected , with the remaining 41 percent deposited into the general fund. The average annual amount collected over the past four years is just over $100,000.

Only two people currently pay for their incarceration; one is millionaire John Brooks, who was convicted of first-degree murder and other crimes in 2008.

The Senate-passed version of the repeal bill contains an amendment designed to ensure that Brooks continues to pay.

Although constitutional provisions prevent any law from being applied retroactively, the senators did not want to take any chances, and included an amendment stating, “this act shall not apply to a person who is or has been subject to an order or directive to pay cost of care prior to the effective date of this act.”

The new law would take effect within 60 days of being signed by the governor.

The little-known provision in state law gained notoriety when the ACLU in October sued the state on behalf of former inmate Eric Cable of Northwood.

Cable was released from the state prison in 2017, and sued the state, claiming negligent medical care while incarcerated.

The state filed a counterclaim for nearly $120,000 to recover the cost of Cable’s incarceration, which the ACLU characterized as retaliatory.

The state is seeking to have the $119,000 offset any award Cable might receive from his lawsuit.

On Feb. 5, the Superior Court Judge Richard McNamara denied the ACLU-NH’s motion and said the issue is best left for the Legislature, which led to HB 518.

The ACLU applauded passage of the bill but declined to comment on how it might affect Cable’s case, if at all.

“We are pleased that the senate passed HB 518 by voice vote,” said ACLU staff attorney Henry Klementowicz, who represents Cable. “This bill is crucial to stopping the arbitrary and terrible practice of the state suing inmates for their incarceration, at the cost of over $40,000 per year.

“People coming out of prison already face many barriers when rebuilding their lives and reintegrating into society, and this practice just makes it harder,” he said.

If signed into law, HB 518 would not affect a different set of state statutes that charge parents or guardians for the cost of juveniles incarcerated at the Sununu Youth Services Center.

When juveniles are sentenced to the Sununu Center or other treatment centers, are enrolled in Children in Need of Services (CHINS) programs, or placed into foster care, an elaborate system kicks in to force parents to contribute to the cost of that care.

The state collected $930,600 from parents in the 2018 budget year.