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.
'No power' However, the case was not won on human rights grounds, but on a point of statutory construction of local government legislation.
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, 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.
AnalysisBy and large, judges have been unsympathetic to the Christian case when people have argued that they don't want to do things like advising homosexual couples.
The tide has been flowing pretty firmly against Christianity in public life and it's caused huge concerns for the churches. They say it's being driven out of public life.
There is a lot of concern that this is not just about pure religion but this is about some of the values that underpin the British way of life.
Of course, from the other side, people like the National Secular Society say the Church and Christianity should not have undue privileges in having their values and their way of doing things upheld.
So there's an argument on both sides but certainly it's been very noticeable in the last few years that the tide's been turning against Christian practices which we've just taken for granted for centuries.
"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 (NSS) 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."
'Great pity' 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 had tried and failed to have prayers stopped, said he felt "disadvantaged and embarrassed" by the practice.
He later left the council because of its "refusal to adjust" its prayers policy.