A federal judge ruled Monday that the U.S. government must seek consent before administering psychotropic drugs to immigrant children held at a Texas facility.

U.S. District Judge Dolly M. Gee in Los Angeles issued a ruling that the federal government violated portions of a longstanding settlement governing the treatment of immigrant children caught crossing the border.

Ms Gee said the government must obtain consent or a court order to give children psychotropic medications at a Texas facility under state law unless it's an emergency.

She also said officials must tell children in writing why they are in a secure facility and that gang affiliation alone doesn't justify such a placement.

"The kids weren't getting notice of why they were sent away," said Holly Cooper, co-director of the Immigration Law Clinic at University of California, Davis, and one of the lawyers representing detained immigrant children. "We view this as a victory."