The Santa Rosa Press-Democrat reported that a judge sided with the family of 5-year-old Brooke Adams.
The Rincon Valley Union School District in Santa Rosa sought to ban the ointment from school grounds because it contains the active ingredient in marijuana.
Authorities argued that allowing Brooke to use the drug at school violated state and federal laws barring medical marijuana on school grounds.
Medical marijuana use in private with a doctor's recommendation is legal in California.
A judge's temporary order permitted Brooke to start school in August while the district's objections were considered. A nurse accompanies Brooke to school and has had to apply the oil three times to treat seizures.
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," said Jana Adams, the girl's mother. "She can just go to school like any other child and we don't have to keep pushing to get what she needs."
The family's lawyer Joe Rogoway 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."
Information from: The Santa Rosa Press Democrat, http://www.pressdemocrat.com
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.