AUGUSTA (AP) — Gov. Paul LePage didn't have the authority to shutter a minimum-security prison last month without obtaining legislative approval, a judge ruled.

Superior Court Justice Michaela Murphy granted a temporary injunction sought by the attorney general, unions, and the Washington County Commission. She concluded that only lawmakers, not the Department of Corrections, have the authority to close the Downeast Correctional Facility.

Murphy wrote that the prison's existence is written into law.

"The court finds that the plain language of the statue mandates the existence of a correctional facility in Washington County unless and until the Legislature passes legislation repealing (the law)," she wrote.

The Associated Press obtained the ruling on Thursday. It was dated Wednesday.

What happens next is unclear. The judge deferred to the corrections commissioner on how to operate the facility, including programs, staffing and pay for workers.

The governor's administration removed inmates from the facility on Feb. 9, even though the facility was funded by lawmakers through the summer.

LePage's office did not immediately respond to a request for comment.

The Republican governor contends the prison is too costly and inefficient to continue operating. The prison costs about $5 million a year to operate and provides jobs and prison labor to the surrounding community.