This verdict came after unsuccessful attempts by pupils to stop Channel 4 from screening its controversial documentary, Dispatches: Undercover Teacher, which captured bad behaviour on a secret hidden camera.
At a Newcastle court, Mr Justice Munby ruled that the rights of parents and inspectors to know what was going on in the classroom outweighed pupils'
right to privacy. He said that the same information could not have been gathered if the programme-makers had declared their objectives to the schools at the start of filming.
The judge's decision contradicts a ruling made by the Press Complaints Commission in 2001, when a journalist went undercover in a London primary for the Evening Standard.
The commission concluded: "Given that virtually every school will or may have some shortcomings, to have accepted the public-interest justification would have been to entitle any journalist to gain access to any school using subterfuge."
The Dispatches documentary, which was screened on July 7, was recorded at two Islington and two Leeds comprehensives. Alex Dolan, a reporter and teacher, filmed scenes of classroom chaos that included a pupil brandishing a fire-extinguisher.
Susan Aslan, of Olswang, the solicitors representing Channel 4, said:
"Children have a right to privacy in school. But there is the right of pupils to learn in class. It's quite clear there were children who wanted to learn, but were being totally let down."
Ms Aslan denied that the Dispatches decision was a reversal of the press commission's verdict.
She said broadcasters are governed by stricter rules than journalists, and are therefore more likely to serve the public interest: "This isn't a signal to every journalist to go into schools to do undercover reporting."
Jack Rabinowicz, education specialist with the legal firm Teacher Stern Selby, agrees the implications are likely to be limited.
"I can just imagine parents getting their knickers in a twist over this," he said. "But children who are behaving badly or teachers who are completely incompetent need to be rooted out.
"If care is taken to make sure children are anonymous, that's sufficient protection when debating the wider issues of how schools are run."