Capistrano Valley High School teacher James Corbett called creationism, "religious, superstitious nonsense" during a history lesson.
The student had alleged that the teacher violated the First Amendment.
A lower court sided with his student that the teacher violated a ban on governmental hostility toward religion.
But the 9th U.S. Circuit Court of Appeals in San Francisco overturned that ruling, saying the teacher had a reasonable belief his comments were acceptable during an advanced placement history lesson.
The appeals court refused to address the constitutionality of the comments.
The Associated Press contributed to this report.