A judge violated a juvenile's free-speech rights when he placed her on probation for posting an expletive-laden entry on MySpace criticizing a school principal, the Indiana Court of Appeals ruled.

The three-judge panel on Monday ordered the Putnam Circuit Court to set aside its penalty against the girl, referred to only as A.B. in court records.

"While we have little regard for A.B.'s use of vulgar epithets, we conclude that her overall message constitutes political speech," Judge Patricia Riley wrote in the 10-page opinion.

• Click here for FOXNews.com's Personal Technology Center.

In February 2006, Greencastle Middle School Principal Shawn Gobert discovered a Web page on MySpace purportedly created by him.

A.B., who did not create the page, made derogatory postings on it concerning the school's policy on body piercings.

The state filed a delinquency petition in March alleging that A.B.'s acts would have been harassment, identity deception and identity theft if committed by an adult.

The juvenile court dropped most of the charges but in June found A.B. to be a delinquent child and placed her on nine months of probation. The judge ruled the comments were obscene.

A.B. appealed, arguing that her comments were protected political speech under both the state and federal constitutions because they dealt with school policy.

The Court of Appeals found that the comments were protected and that the juvenile court had unconstitutionally restricted her right of free expression.

There was no number for Shawn Gobert in publishing phone listings. The Associated Press left a message seeking comment Monday at Greencastle Middle School.

FOXNews.com is owned and operated by News Corporation, which also owns and operates MySpace.com.