After Arizona Republicans learned that a school district in their state offered a Mexican-American studies program, they started to worry the courses were teaching students to hate white people. But when state Republicans passed a law banning the program in 2010, they were the ones being racist, a federal judge ruled late Tuesday night.

“The Court is convinced that decisions regarding the MAS [Mexican-American studies] program were motivated by a desire to advance a political agenda by capitalizing on race-based fears,” Judge A. Wallace Tashima wrote in a scathing opinion.

After years of litigation, Tashima’s decision found the law unconstitutional and ordered each side to present him with a remedy in the coming weeks. While states have enormous discretion when deciding what curriculum to teach in public schools, the ruling simultaneously sends a warning to other state legislatures as well as a sign of encouragement to numerous other cities currently launching ethnic studies courses.

The controversy over the Tucson school district’s Mexican-American studies program started in 2006 when civil rights activist Dolores Huerta spoke at Tucson High Magnet School. Referring to the flurry of anti-immigration legislation — like bills punishing people who employed undocumented immigrants, Huerta declared that “Republicans hate Latinos.”

“The Court is convinced that decisions regarding the MAS [Mexican-American studies] program were motivated by a desire to advance a political agenda by capitalizing on race-based fears.”

State Republicans were outraged. They sent a conservative Latina, Margaret Dugan, to the school to make a counter speech. Students, however, walked out in protest. After that, although Huerta hadn’t been invited to the school as part of the Mexican-American studies program, then-state superintendent Tom Horne wrote an open letter to Tucson citizens recommending the program be quashed in June 2007.

When the local school board didn’t act on Horne’s recommendation, he took the cause to the Republicans in the state Legislature, who passed a bill that effectively banned the program.

The language of the law, which took effect in 2010, prohibited classes that promoted the overthrow of the U.S. government or resentment toward a race or class of people, are designed specifically for a particular ethnic group, or “advocate ethnic solidarity instead of the treatment of pupils as individuals.” So far, that’s only applied to the Tucson school district’s Mexican-American studies program.

As a result, teachers and students there immediately sued, arguing the law was racist and violated their rights to free speech and equal protection. State officials, however, maintained the program promoted reverse racism by teaching Hispanic students to hate white people.

John Huppenthal, then-state senator and chairman of the state legislature’s education committee, saw, and still sees, the Mexican-American studies program as a kind of Trojan Horse for anti-white, anti-free market ideas.

“That this oppressed-oppressor framework has some kind of foundation in reality and that it’s useful — I think it’s totally worthless,” he told VICE News before the judge’s ruling. “I think it’s less than worthless. I think it’s toxic. We live in the United States. Every single door out there is open. To me, that’s just BS. That’s wasted mental energy.”

Huppenthal used that mentality to campaign for state superintendent in 2011. Red-hot ads that read, “Stop La Raza,” slang for the Mexican-American studies program, propelled him to victory. But Huppenthal had only ever attended one class before determining the program violated the state’s law. He finally ordered the program to shut down in January 2012.

In Tuesday’s ruling, Judge Tashima found the state’s argument that the Mexican-American studies program constituted reverse racism “had no legitimate basis.” And to determine that the state had, in fact, acted with racist intent, Tashima relied partially on blog comments Huppenthal wrote from 2010-2012 that compared the teachers to Hitler and the program to the KKK and advocate for only speaking English.

“The ruling makes it clear this was not about prohibiting hate speech, it says they [Huppenthal and Horne] were acting with hate speech themselves,” said Isabel Medina, a constitutional law professor at Loyola University.

But Huppenthal thinks the judge misinterpreted his actions.

“The idea that I have racial animus, that’s a frickin’ joke. What I have are deep-fired beliefs about what it takes to get out of poverty, regardless of whether you’re black, brown, or white,” he told VICE News Wednesday in response to the ruling. “So you can interpret those really strong beliefs as being racist, but that’s false. They are anti-racist.”

At the height of the program, one in five Tuscon students at district schools offering Mexican-American studies courses was taking a class — and around 90 percent of them were Latino. The coursework included Mexican-American history and literature. Students read books like The Devil’s Highway, about a border crossing gone wrong, and analyzed Shakespeare’s The Tempest through the lens of colonialism. The program also offered art electives and weekly elementary school classes.

“We came to a realization that this is something that was sorely missing in the schools,” said Sean Arce, who helped launch the program and taught the first class at Tucson High School in 1998 and testified at the trial in July. “[Students] did not see themselves reflected in the curriculum.”

Students themselves said the classes empowered them, brought them together, and gave them the tools to relate to and compete with their non-Latino peers. They were also more likely to pass standardized tests and graduate after joining the program, according to a 2012 study by a team of education scholars as the University of Arizona.

“I saw people that weren’t the typical A-plus student that were just like really engaged in this class,” said one former student, Alfred Chavez.

Since 2012, when Mexican-American studies classes stopped, similar programs have cropped up around the country. California plans to put ethnic studies in all public high schools this year, and so do cities like Portland, Seattle, and Albuquerque. Austin is working on a pilot program for six high schools to start next year.

“I believe that every student deserves to see themselves in the curriculum at school,” said Maya Arce, a former student and daughter of teacher Sean Arce. “We decided to [sue the state] for future generations because I want to give the opportunity to people like my younger brother.”

After seven years of litigation and countless protests, the students and teachers finally won their fight. The ruling will likely caution other state legislatures against trying to eliminate ethnic studies courses, according to Medina.

“This is a case that makes it clear how closely tied sometimes public education can be to political battles,” she said. “This court sends a message that when government acts with racial animus it will not be tolerated.”