(Reuters) - A federal judge has overturned an Arizona ban on ethnic studies courses aimed at Hispanic students, saying it was motivated by racial discrimination and violated pupils’ constitutional rights.

The decision by Judge A. Wallace Tashima issued on Tuesday came in response to a lawsuit by students and parents challenging the law, which ended a Mexican American Studies, or MAS, program run by the Tucson school district.

“The Court is convinced that decisions regarding the MAS program were motivated by a desire to advance a political agenda by capitalizing on race-based fears,” Tashima wrote in his ruling.

Officials with the Arizona Department of Education were not immediately available for comment.

A Tucson Unified School District member, Kristel Ann Foster, said she was “elated” to be able to restore the program to classrooms.

In 2006, Arizona’s then-schools superintendent and former attorney general, Thomas Horne, began a probe into MAS after an incident when a labor activist told students that Republicans were racist. Horne concluded the program violated school code, and the state threatened to withhold funds until it was stopped.

Tashima, however, backed a study conducted in 2012 - the year the program was dropped from the syllabus in Tucson - which found MAS helped improve the graduation rates and test scores of some of the district’s worst-performing students.

One of those, Alfred Chavez, 27, said he had been on the verge of dropping out in 2006 when he signed up for MAS at Tucson High School. He credits the classes with keeping him in school and propelling him toward a career in education.

“They didn’t just appeal to the A+ student. They appealed to street kids, the marginalized population,” said Chavez, who works as a program specialist at Mesa Community College near Phoenix. “It turned them on to education.”

About 64 percent of Arizona’s school students are Hispanic, according to state figures. The MAS program included units on Mexican-American history, art and literature.

The attorney for the parents and students who brought the lawsuit, Steve Reiss, described the ruling as an “extraordinary” win.

“To show that a state passed and implemented a law with discriminatory intent is extremely hard these days,” Reiss said.

Horne said public schools should teach students from different backgrounds to treat each other as individuals.

“This decision promotes a program that does the opposite: divides students by race and promotes ethnic chauvinism,” he said in a statement.