SAN JOSE, Calif., Feb. 28— A Stanford University speech code that sought to shield students from bigotry by banning insults based on race and sex was struck down today by a Superior Court judge.

The judge, Peter Stone of Santa Clara County Superior Court, ruled that the code was unconstitutionally broad and based on content.

Robert J. Corry, one of nine Stanford students who sued the university last year over the code, said: "This is a victory for academic freedom and free speech. We think this is an important case for not only Stanford, but students at universities across the nation."

Mr. Corry, now a lawyer in Sacramento, Calif, and the other plaintiffs argued that the code violated First Amendment rights and discouraged discussion of controversial topics.

A lawyer for Stanford did not return a call seeking comment. University officials were also not immediately available for comment.

Stanford had said that the speech code barred only "fighting words" expressing hatred and contempt and aimed directly at individuals and small groups. It argued that the wording of the code clearly said the code proscribed no idea, no matter how offensive.

At the heart of the case is the question of how far universities can go to fight hateful speech without violating freedom of expression. More than 150 colleges and universities have tried to regulate such speech, according to a survey by the Freedom Forum First Amendment Center.

But several institutions have abolished or narrowed their codes because of criticism and legal challenges.

The Stanford code, adopted in 1990, forbids use of "gutter epithets and symbols of bigotry."

The university had argued that the code stemmed from fundamental Stanford principles: students are expected to show respect for others' rights and students should be protected from "discriminatory harassment."

Mr. Corry and eight other law students sued Stanford last May, arguing that the speech code violated a 1992 state law that forbids universities to restrict speech that would be protected off campus.

Stanford challenged the application of that law.

The university said that using it to strike down the speech code would infringe on the private university's own First Amendment rights by forcing it to allow unacceptable speech on its property.

Judge Stone, however, said the state law did apply to the Stanford case.

The university has an enrollment of more than 13,000, including about 6,500 undergraduates.