Ouseley said: "A local authority has no powers under section 111 of the Local Government Act 1972 to hold prayers as part of a formal local authority meeting or to summon councillors to such a meeting at which prayers are on the agenda.

"The saying of prayers in a local authority chamber before a formal meeting of such a body is lawful provided councillors are not formally summoned to attend."

Keith Porteous Wood, chief executive of the National Secular Society, welcomed the ruling.

"We are delighted that the court has decided to make a ringingly secular decision, which will make the saying of prayers of whatever religion unlawful in local councils.

"This will mean no one will be disadvantaged or feel uncomfortable in performing their duties as a councillor in meetings."

The Christian Institute said: "The practice of saying prayers at Bideford town council meetings is understood to date back to the days of Queen Elizabeth I.

"The council has, recently, twice voted in support of continuing with the prayers. Individual councillors were free to not take part in the prayers if they wished, and the register of attendance was not taken until after the prayers had finished.

"Nevertheless, a court case was brought by the National Secular Society and a secularist former councillor, Mr Clive Bone, against Bideford town council."

The Christian Institute's spokesman, Simon Calvert, said: "We welcome the finding that the saying of prayers isn't discriminatory, or a breach of equality laws, or human rights laws. But it is extraordinary to rule that councils have no lawful authority to choose, if they so wish, to start their formal meetings with prayers. That is simply wrong.

"The logic of the ruling is that councils would also be going beyond the law if they took a vote and decided to start each formal council meeting with the national anthem."

Bone, the Bideford councillor who launched the action, said he was "delighted" when the Guardian broke the news of the judgment to him.

He said he was horrified when he became a councillor in 2007 to find prayers were being said. "It was outdated, antiquated and a turnoff," he said. He twice championed motions trying to get the practice halted but they were defeated.

Bone argued the saying of prayers was bad for local democracy. "It sends out a signal that local governments are for particular types of people and not for everyone," he said.

Tony Inch, a councillor who supported the prayers, said the ruling was a "big shock and a shame". He added: "We seem to be going from one crisis to another. It has implications for councils up and down the country. Where is it going to end? It's eroding the whole basis of Christian life in this country."

The bishop of Exeter, the Right Rev Michael Langrish, said he would encourage councils in his diocese, including Bideford, to continue to say prayers before the statutory business of the meeting began.

He said it was a great pity that "a tiny minority are seeking to ban the majority" of people who were for the saying of prayers.

Speaking on the BBC, he said: "I've got no doubt the agenda of the National Secular Society is inch by inch to drive religion out of the public sphere. If they get their way it will have enormous implications for prayers in parliament, Remembrance Day, the jubilee celebrations, even the singing of the national anthem."

"The wider issue has got to be resisted. It strikes right at the heart of our understanding of ourself as a society. No one is compelled to participate in these activities. There is complete freedom. That freedom has to be respected."