CHICAGO (CBS) – A federal appeals court has ruled that school officials in Naperville were not justified in forbidding a student from wearing an anti-gay T-shirt.

The U.S. 7th Circuit Court of Appeals ruled Tuesday that Indian Prairie School District 204 could not prohibit students from expressing their religious views.

The case stemmed from an April 2006 incident at Neuqua Valley High School in Naperville. Heidi Zamecnik, a senior at the school at the time, got in trouble for wearing a T-shirt reading, “MY DAY OF SILENCE, STRAIGHT ALLIANCE” on one side, and “BE HAPPY, NOT GAY,” on the other.

The shirt was in response to the National Day of Silence. It’s an event where students don’t speak to highlight discrimination against the gay and lesbian community.

The school’s dean demanded Zamecnik remove it or be sent home for the day, citing school policy that prohibits clothing with offensive messages.

After speaking with Zamecnik’s mother by phone, all agreed to change the shirt to read, “Be Happy, Be Straight.” However, the dean instead had a female counselor cross the words “Not Gay” off Zamecnik’s shirt so it simply read “Be Happy.”

In 2007, Zamecnik and another student, Alexander Nuxoll, filed a federal lawsuit, claiming the order to remove the shirt was a violation of civil rights.

Nuxoll had wanted to wear a similar shirt to class. He had twice filed for an injunction that would suspend the school’s policy that prevented him from wearing the T-shirt.

Twice the courts denied that request. But in April of 2008, the 7th Circuit Court reversed the lower courts’ rulings, saying the district court must order Neuqua to suspend its ban on the shirt while the civil rights lawsuit filed by Nuxoll and Zamecnik proceeded.

In ruling on the case, the 7th Circuit opined: “[A] school that permits advocacy of the rights of homosexual students cannot be allowed to stifle criticism of homosexuality. The school argued [and still argues] that banning ‘Be Happy, Not Gay’ was just a matter of protecting the ‘rights’ of the students against whom derogatory comments are directed. But people in our society do not have a legal right to prevent criticism of their beliefs or even their way of life.”

The Arizona-based Alliance Defense Fund, a legal alliance of Christian attorneys that represented the students in the lawsuit, called the decision a victory for free speech.

“Christian students shouldn’t be discriminated against for expressing their beliefs,” said Nate Kellum, senior counsel for the Alliance Defense Fund. “The 7th Circuit has, once again, rightly recognized the First Amendment-protected rights of students on a public school campus. In an environment that freely allows speech that promotes homosexual behavior, the school simply cannot shut out the opposing viewpoint.”

When reached on Tuesday evening, District 204 board President Curt Bradshaw said he could not yet comment on the ruling.

“The board hasn’t been briefed by our attorneys, so I can’t yet speak to what this ruling means or doesn’t mean for our district or students,” he said.

Both students involved in the lawsuit have since graduated.

The Sun-Times Media Wire contributed to this report.