JACKSON, Miss. — A federal judge is taking charge of Mississippi's mental health system, saying that attorneys for the federal government have proved the state isn't doing enough to serve people outside the confinement of mental hospitals.

"The United States has met its burden and shown that despite the state's episodic improvement, it operates a system that unlawfully discriminates against persons with serious mental illness," U.S. District Judge Carlton Reeves wrote late Tuesday in a ruling on a federal lawsuit.

Reeves said he wants to appoint an outside expert to oversee changes, saying he's "keenly aware of the judiciary's limitations" in cases like this. He ordered the state and federal government to each suggest three possible names to act as a special master, along with a proposal for that person's role.

Until Reeves decides on the special master's role, the depth of his intervention into the mental health system won't be clear.

It's also unclear if the state will appeal the ruling, but lawyers appeared to be laying the grounds for an appeal in a month-long trial this summer. Attorney General Jim Hood announced a news conference later Wednesday to discuss the ruling.

The U.S. Justice Department argued that Mississippi's movement toward community services was far too slow, forcing hundreds or thousands of people into avoidable hospital stays. Reeves found that Mississippi is violating the Americans with Disabilities Act, as well as a 1999 U.S. Supreme Court decision that said "unjustified" mental hospital confinement is illegal.

The judge rejected Mississippi's arguments that it was progressing on its own and that a judge couldn't find it in violation. Reeves wrote that the law and court decisions "protect persons trapped in a snail's-pace deinstitutionalization."

"The United States' experts provided dozens of examples of individuals who were unnecessarily hospitalized or hospitalized too long because they were excluded from community-based services," the judge wrote.

The federal government catalogued a litany of alleged transgressions during the trial, including mentally ill people held in jails because crisis teams don't respond; people forced to live far from their family because services aren't available in their hometowns; and people who make repeat trips to state mental hospitals because there's no effective planning for them to transition to community services and the most intensive kinds of services aren't made available.

Reeves said that even in some cases where community-bases services are supposed to be available, that availability is illusory. He cited the case of Adams County, whose sheriff testified that the regional community mental health center doesn't respond to his calls.

"Geographic availability does not always translate into true accessibility," Reeves wrote.

Joy Hogge, director of mental health advocacy group Families As Allies, said it's been clear since 2011, when Mississippi was cited by the federal government, that it was violating the law.

"I hope this will be an opportunity for our state to look at how the system should be structured ... so that all of the parts work together and so that we don't have the gaps that lead to the problems that were referenced in the ruling," Hogge said Wednesday.