A test case bid to outlaw prayers before local council meetings has been won by the National Secular Society and an atheist councillor.
They challenged the practice of Bideford town council, Devon, of having religious prayers on meeting agendas.
The ruling could lead the way to prayers being banned in other councils and public meeting places, with one MP already threatening to introduce a private members bill to overturn he decision.
On Friday Mr Justice Ouseley, sitting in London, ruled: "The saying of prayers as part of the formal meeting of a council is not lawful under section 111 of the Local Government Act 1972, and there is no statutory power permitting the practice to continue."
The legal challenge was launched in July 2010 after the society was contacted by Clive Bone - a non-believer who was then a Bideford councillor.
Mr Bone later left the council because of its "refusal to adjust" its prayer policy.
Former councillor Clive Bone
Society lawyers argued that council members who were not religious were being "indirectly discriminated against", in breach of human rights laws.
But the case was not won on human rights grounds, but on a point of statutory construction of local government legislation.
The judge gave the town council permission to appeal against his ruling, acknowledging the case raised issues of general public importance.
The judge made two formal declarations in order to sum up the effect of his landmark ruling which will affect local councils up and down the country.
He said: "A local authority has no power under section 111 of the Local Government Act 1972, or otherwise, 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."
But he added in a second declaration: "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."
In his ruling, the judge said: "There is no specific power to say prayers or to have any period of quiet reflection as part of the business of the council."
Referring to Bideford, he said: "The council has on two occasions by a majority voted to retain public prayers at its full meetings.
"But that does not give it power to do what it has no power to do."
The judge said the council made attendance at prayers optional "because it recognises that councillors, of whatever religion or none, may not wish to attend prayers as part of a political meeting..."
But this turned a council meeting "into a partial gathering of those councillors who share a particular religious outlook, or are indifferent to it or - as in the case of Mr Bone - too embarrassed to leave in public".
"That cannot satisfy section 111. The same objection does not apply to a few minutes silent reflection on the duties ahead, which each can observe in their own way."
The judge said it was not for the court "to rule upon the likelihood of divine guidance" becoming available to council members through prayer.
Then he added: "I do not think that the 1972 Act dealing with the organisation, management and decision-making of local councils should be interpreted as permitting the religious views of one group of councillors, however sincere or large its number, to exclude or, even to a modest extent, impose burdens on or mark out those who do not share their views and do not wish to participate in their expression.
"They are all equally-elected councillors."
The Bishop of Exeter, the Rt Rev Michael Langrish, condemned the ruling.
He told BBC News: "Every time there is a survey of religious beliefs in this country, around 70% of the population profess a faith and to saying private prayers.
"At the House of Lords we began with prayers this morning. Prayers were said by a considerable amount of peers. I don't think you will find anyone in the House of Lords who will seriously suggest we should end that practice."
The Rt Rev Michael Langrish
Keith Porteous Wood, executive director of the National Secular Society (NSS), welcomed the court ruling, saying: "There is no longer a respectable argument that Britain is a solely Christian nation, or even a religious one."
He said: "An increasing proportion of people are not practising any religion, and minority faiths are growing in number and influence."
Prayers had been the cause of tension in a number of local councils and led to difficulties between faiths, underlining the "need for shared civic spaces to be secular and available to believers and non-believers alike on an equal basis".
He said: "This judgment is an important victory for everyone who wants a secular society, one that neither advantages nor disadvantages people because of their religion or lack of it."
Today's ruling would apply to the formal meetings of all councils in England and Wales - "the majority of which are thought to conduct prayers as part of their meetings".
But he stressed the judgment did not extend generally to "religious worship in public places", for example remembrance services, or councillors voluntarily attending them.
Mr Porteous Wood said: "Acts of worship in council meetings are key to the separation of religion from politics, so we're very pleased with the judgment, and the clear secular message it sends - particularly the statement made about the 1972 Act.
"The NSS is not seeking to deprive those who wish to pray the opportunity to do so - we fight to retain freedom of religion and belief.
"The judgment clearly states that religious freedoms are not hindered, as councillors who wish to do so are free to say prayers before council meetings.
"Our interest in this issue was prompted by a complaint from a Bideford town councillor Clive Bone, who felt uncomfortable at having to sit through prayers, homilies and requests for divine guidance while carrying out his formal duties as an elected councillor.
"The only alternative to this discomfort was to walk out, unbidden by the mayor, which would look discourteous to those in the public gallery.
"We sought the judicial review only after Bideford had rejected compromises made by (now former) councillor Bone and the NSS for prayers before the meeting, or a period of silence during the meeting.
"Prayers have been the cause of tension in a number of local councils. When Portsmouth Council allowed a Muslim imam to say a prayer, one Christian councillor walked out of the meeting, later saying 'I do not believe we are praying to the same god'.
"Meanwhile, councillors in Shropshire called a fellow councillor 'disgusting' when he wore headphones during prayers."
Following its announcement, community Secretary Eric Pickles used Twitter to condemn the decision:
Former Lib Dem MP Evan Harris, a scientist and a spokesman for humanism, called the decision a "victory".