Updated

A 5-year-old California girl can keep bringing a cannabis-based drug to school—used for emergency treatment of a rare form of epilepsy—a judge ruled Friday.

The judge sided with the family of Brooke Adams, who attends kindergarten in Santa Rosa.

The Rincon Valley Union School District had sought to ban the ointment from the school because it contains the active ingredient in marijuana.

Officials said allowing Adams to use the drug at school would violate state and federal laws barring medical marijuana on school grounds.

In California, medical marijuana use in private with a doctor's recommendation is legal. A total of 30 states and the District of Columbia allow medical marijuana usage.

OHIO BAR LOSES LIQUOR LICENSE WHEN FOOD STAMPS ARE USED TO BUY DRUGS, LAP DANCES

The judge's temporary order permitted the young girl to start school in August while the district's objections were considered. A nurse accompanies Adams to school and has had to apply the oil three times to treat seizures.

cannabis ruling AP 2

In this Monday, July 23, 2018, photo minutes before having a seizure, Brooke Adams, 5, plays with her toys with her mother, Jana at their home in Santa Rosa, Calif. (AP)

Judge Charles Marson made the order permanent on Friday. Marson is a judge in the state office of Administrative Hearings' Special Education Division, which handles disagreements between school districts and parents of children with disabilities.

“I was so overwhelmed with emotion and joy that we don't have to fight anymore after a battle of over two years,” Jana Adams, the girl's mother, told the Associated Press.

“She can just go to school like any other child and we don't have to keep pushing to get what she needs,” her mother added.

BANANA SHIPMENT CONTAINED NEARLY $1.8M IN COCAINE, AUTHORITIES SAY

Joe Rogoway, the family's lawyer, said he hopes the ruling opens the door for other students who say they need to use a cannabis-based drug on campus for medical reasons.

District officials said they were reviewing the decision and haven't decided whether to appeal. Assistant Superintendent Cathy Myhers said the district is relieved to have legal guidance on the issue.

"We are pleased with the decision and guidance," Myhers said.  "We are happy to have a decision that supports our ability to educate and serve this student in our public schools."

The Associated Press contributed to this report.