A Devon town council acted unlawfully by allowing prayers to be said at meetings, the High Court has ruled.
Action was brought against Bideford Town Council by the National Secular Society (NSS) after atheist councillor Clive Bone complained.
Mr Justice Ouseley ruled the prayers were not lawful under section 111 of the Local Government Act 1972.
However, he said prayers could be said as long as councillors were not formally summoned to attend.
The judgement was being seen as a test case which could affect local councils across England and Wales.
Mr Justice Ouseley ruled the prayers as practised by Bideford Town Council had been unlawful because there was no statutory power permitting them to continue.
The NSS, which said prayers had no place in "a secular environment concerned with civic business", argued the "inappropriate" ritual breached articles 9 and 14 of the European Convention on Human Rights, which protect an individual's right to freedom of conscience and not to face discrimination.
However, the case was not won on human rights grounds but on a point of statutory construction of local government legislation.
Mr Justice Ouseley 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."
He told the court: "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 acknowledged the case raised issues of general public importance and gave the council permission to appeal.
Speaking after Friday's outcome, Eric Pickles, Secretary of State for Communities and Local Government, said the ruling was "surprising and disappointing".
He said: "Public authorities - be it Parliament or a parish council - should have the right to say prayers before meetings if they wish."
Anthony Inch, a Bideford town councillor and Torridge district councillor, said he hoped there would be an appeal leading to the ruling being overturned.
"I'm disgusted, surprised and saddened by the decision," he said.
Simon Calvert, of the Christian Institute, said: "We are pleased that the court has said the saying of prayers at meetings does not breach human rights laws.
"But it is bizarre that they should be declared unlawful because of the 1972 Local Government Act."
He added: "The judge's finding that the Local Government Act doesn't give local authorities power to include prayers as part of their formal meetings - we think that's extraordinary.
"I mean we're talking about a practice that goes back to the Elizabethan era.
"And the logic of the judge's ruling may be that it could also be unlawful for a council to start its meeting with the beginning of the national anthem. It may even throw local authorities' Diamond Jubilee celebrations up in the air."
Keith Porteous Wood, executive director of the National Secular Society 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."
He added: "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 Bishop of Exeter, the Right Reverend Michael Langrish, said he would encourage councils in his area to continue holding prayers before the start of their statutory business.
He added: "I think it's a great pity that a tiny minority are seeking to ban the majority, many of whom find prayers very, very helpful, from continuing with a process in which no-one actually has to participate."
The legal challenge was launched in 2010 after the NSS was contacted by Mr Bone, who was a Bideford town councillor at the time.
Mr Bone, who ended up leaving the council because of its "refusal to adjust" its prayers policy, said on Friday: "Quite frankly delighted. I'm not surprised, I expected to win.
"The law is the law and local authorities have to obey the law."
He added: "Local government is for everybody, it should be equally welcoming to everybody, whatever they believe.
"This has got nothing to do with intolerance towards religion.
"Religious freedom is an absolute right and so is freedom from religion an absolute right, in my view."