DES MOINES, Iowa (AP) — Iowa Gov. Terry Branstad acted within his constitutional authority when he vetoed funding for two state-run mental health care facilities last year and closed them, the state Supreme Court ruled Thursday.

Twenty legislators and Danny Homan, the president of the American Federation of State, County and Municipal Employees, the largest state employee union, had sued Branstad. They claimed a section of state law requires Iowa to have four mental health care institutes — one each in Mount Pleasant, Clarinda, Cherokee and Independence.

Branstad closed the Mount Pleasant and Clarinda institutes in June 2015 when he vetoed the Legislature's funding for them. The lawsuit also claims the law creating the state facilities limits Branstad's ability to close the facilities by vetoing their funding.

The court concluded Thursday that the law doesn't require the continued existence of state mental health institutes.

The unanimous decision, written by Justice David Wiggins, delves deeply into the history of the Legislature's creation of the mental health institutes and concludes that lawmakers changed the language of the laws over the years and eliminated permanently established facilities.

There is nothing in the history of state law "that leads us to construe the general assembly's intent is to mandate the continued existence of the state mental health institutes," Wiggins wrote.

He also concluded the statutes don't limit the governor's ability to veto appropriated funds for such institutions.

The decision agrees with a November 2015 ruling by District Court Judge Douglas Staskal and dismisses the lawsuit.

"Today's unanimous Supreme Court decision affirms the Governor's action by allowing more Iowans to have access to quality mental health care and substance abuse treatment than ever before," Branstad spokesman Ben Hammes said in a statement. "The state's mental health care redesign allows Iowans to access treatment in a community-based setting and through more modern means."

Mark Hedberg, the plaintiffs' attorney, said he hadn't read the ruling and may comment on it later.

Democratic Sen. Pam Jochum, one of the plaintiff lawmakers in lawsuit, said the decision will enable Branstad and legislative Republicans "to take additional steps to further reduce access to mental health services for thousands of Iowans."

She said they've underfunded community-based mental health services after closing the two state-run facilities.

"This rips another hole in the health care safety net for hundreds of thousands of vulnerable Iowans," she said.

The GOP will control the Legislature and governor's office in January.

Branstad removed funding for the two mental health facilities when he released his budget proposal in January 2015. Some lawmakers and health care providers criticized the move, but a legislative push to restore some funding was vetoed by Branstad.

Branstad claimed the facilities were housed in old buildings, were outdated and patients could receive treatment elsewhere. Critics argued the facilities were well maintained and some patients with special treatment needs had no other place to go.

Branstad and the Iowa Department of Human Services which oversaw the mental health facilities were further criticized after three men from the Clarinda facility last year died within weeks of the state's transfer of them to a private nursing home.

The mental health institutes in Cherokee and Independence remain open and served 717 individuals in the most recent fiscal year and employ 366 workers.