The Maine Department of Corrections says it will allow a Caribou man to receive medication while in prison to treat his opioid disorder.

In July, 30-year-old Zachary Smith sued through the American Civil Liberties Union, saying he was being denied his rights to medication in prison under the Americans with Disabilities Act.

The Portland Press Herald reports Smith takes Suboxone to help recover from opioid use disorder. Smith was allegedly denied the medication after being in recovery for more than five years. Some states allow medication-assisted treatment in jails and prisons.

The ACLU says the settlement announced in court on Friday will spare Smith unnecessarily painful withdrawal. A federal judge still needs to formally approve the agreement.

Smith is due to report to jail for a nine-month sentence for a domestic assault against a male family member. His term will be served either at the Aroostook County Jail in Houlton or at the Maine Correctional Center in Windham.