A panel of the 9th U.S. Circuit Court of Appeals said by a 2-1 vote that having teachers lead children in reciting the pledge is not an unconstitutional government establishment of religion because the purpose of the pledge is patriotic, not religious.
Judge Carlos Bea wrote, "The Pledge of Allegiance serves to unite our vast nation through the proud recitation of some of the ideals upon which our republic was founded."
Judge Stephen Reinhardt said in a lengthy dissent that the words "under God" - inserted by Congress during the Cold War in 1954 - had an "undeniably religious purpose."
The court ruled in a lawsuit filed in federal court in Sacramento by Michael Newdow, an atheist father and emergency room doctor, and three other parents.
It was the second time that Newdow's challenge to the pledge came before the court.
In an earlier ruling in 2002, a 9th Circuit panel by a 2-1 vote said that requiring children to hear the pledge with the reference to God was unconstitutional.
That ruling created a national firestorm of controversy. It eventually reached the U.S. Supreme Court, which dismissed the case on a technical ground, saying that Newdow didn't have standing to sue because he didn't have legal custody rights over his daughter's education.
Newdow then refiled the case with three other parents who did have custody of their children.
The lawsuit challenged a California education law that mandates "daily appropriate patriotic exercises" in public schools and says that reciting the pledge fulfills the requirement. Children are allowed to opt out of reciting the pledge.
Newdow was not immediately available for comment on the ruling, which could be appealed to an expanded panel of the circuit court and then to the Supreme Court.