SAN FRANCISCO — A federal judge on Friday rejected California’s motion to regain control of mental health care in its prisons, ruling that the quality of care failed to meet standards required by the Constitution. The move dealt a blow to Gov. Jerry Brown’s broader efforts to bring the prisons back under the state’s authority.

In a ruling handed down about 90 days after the state first argued that enough improvements had been made to mental health care after 18 years of outside control, Judge Lawrence K. Karlton of United States District Court in Sacramento wrote that there were “ongoing constitutional violations” and that court oversight “remains necessary to remedy those violations.”

In a statement, Deborah Hoffman, a spokeswoman for the California Department of Corrections and Rehabilitation, said that the judge had not given enough weight to experts and evidence showing that mental health care in the prisons was “a model for the nation.” She said that the state will appeal.

Since January, Mr. Brown has made it a priority to regain greater control of the state’s 33 adult prisons, the nation’s biggest corrections system. In addition to mental health care, he is seeking to overturn an order by the United States Supreme Court to further reduce prison overcrowding. In 2011, the Supreme Court ruled that conditions in California’s prisons were so poor that they violated the Eighth Amendment’s ban on cruel and unusual punishment. In 2006, the state prisons held more than twice the population for which they had been designed.