PHOENIX — A judge upheld the levy on hospitals for Medicaid expansion as legal on Wednesday, preserving health care for some 350,000 Arizonans — at least for the time being.

Maricopa County Superior Court Judge Douglas Gerlach rejected arguments by legislative foes of the expansion that the levy that is financing the expansion is actually a tax. Instead, he accepted arguments by attorneys for the Arizona Health Care Cost Containment System, the state’s Medicaid program, that it fits the definition of an assessment because it was levied by the AHCCCS director and not lawmakers themselves.

That distinction is critical.

The Arizona Constitution requires a two-thirds vote of both the House and Senate to increase taxes. The 2013 measure, pushed through by Jan Brewer when she was governor, did not get that margin.

Had Gerlach decided otherwise, the $270 million in state dollars used to fund the expansion would have gone away. That, in turn, would have stopped the flow of federal dollars available through the Affordable Care Act, forcing the state to kick those 350,000 people who have been added since the expansion took effect off the rolls.

Wednesday’s ruling is unlikely to be the last word. Senate Majority Leader Steve Yarbrough, R-Chandler, who opposed Medicaid expansion and was one of the plaintiffs in the lawsuit, said an appeal is all but certain.

And Yarbrough said it is legally irrelevant if a higher court sides with him and hundreds of thousands of people lose health care. He said that’s not the issue.

“It was never, ever, in my mind about the folks who were being funded or not,” he said. “It was simply about what the constitution says and what it contemplates.”

But House Minority Leader Eric Meyer, D-Paradise Valley, countered that Wednesday’s ruling is about real people. And he cheered the decision.

“It’s good news for the Arizona citizens that now have health care in our state that had gone uncovered for years,” he said. And Meyer said the alternative is not acceptable.

“I practiced emergency medicine,” he said.

“All those patients came to the ER without insurance,” Meyer continued. “Now they have physicians they can go to in the community.”

Gov. Doug Ducey opposed Medicaid expansion while he was state treasurer. On Wednesday he said he had not read the decision.

“I’ve been outspoken that I think Obamacare is a monumental disaster and a real failure,” referring to the Affordable Care Act the way it is often referred to by foes. “But if the courts have made that decision, we’ll follow the law.”

Goldwater Institute attorney Christina Sandefur, who represents lawmakers who challenged the levy, said Wednesday’s ruling, unless overturned, sets a bad precedent. She said it allows a simple majority of lawmakers to empower an “unelected administrator” to impose a new levy, “even though the Legislature would need a supermajority to impose that same levy itself.”

At the heart of the fight is a 2004 voter-approved law that requires AHCCCS to provide free care to virtually everyone below the federal poverty level.

In 2011, however, Brewer and state lawmakers opted not to provide coverage for single adults as a method of balancing the budget. Efforts to challenge that decision were rebuffed by the courts.

But two years later, after Congress approved the Affordable Care Act, Brewer figured she could leverage those federal dollars to restore coverage for the 60,000 single adults who had since been cut.

There was one problem, though: To qualify for the new federal dollars, Arizona had to expand its coverage to everyone up to 138 percent of the federal poverty level, about $27,000 a year for a family of three. And while the feds picked up some of that burden, there was still a cost to the state.

The Brewer-crafted law allowed AHCCCS director Tom Betlach to levy what she called an “assessment” on hospitals to pay that share. And the hospitals went along after Betlach promised to craft it so that every hospital chain would actually make more by having patients with insurance than what they were paying.

Greg Vigdor, president of the Arizona Hospital and Healthcare Association, acknowledged as much in a statement praising Wednesday’s ruling and saying facilities have benefited from the program.

“Before this legislation, many hospitals — especially smaller facilities and those in low-income areas —were teetering under the weight of emergency medical care provided to individuals with no insurance or ability to pay,” Vigdor said. By contrast, he said the costs of “uncompensated care” for the first half of 2015 is 40 percent less than the same period in 2013.

The plan was approved when Brewer got a handful of Republicans to vote with all the Democrats. But the margin was less than two-thirds, meaning that if the levy were a tax, there were enough votes to block it.

Brewer initially tried to kill the lawsuit by arguing only those affected could sue, meaning the hospitals. She said it was irrelevant that they were not interested in doing so, given the financial benefit they reaped.

But the Arizona Supreme Court said the dissident lawmakers also could mount a challenge. The justices said if this proved to be a tax, then their votes — and their ability to have stopped the levy — was unconstitutionally taken away.