A group of 27 church leaders launched a judicial review at the Court of Session arguing the Scottish government acted beyond their powers under emergency legislation.
Lord Braid agreed the regulations went further than was lawfully allowed.
The ruling comes two days before communal worship is due to resume.
But Lord Braid said those who brought the judicial review were entitled to have the regulations declared unlawful.
He said the Scottish government regulations disproportionately interfered with the freedom of religion secured in the European Convention on Human Rights.
He added: “It is impossible to measure the effect of those restrictions on those who hold religious beliefs.
“It goes beyond mere loss of companionship and an inability to attend a lunch club.”
However, Lord Braid emphasised that he was not saying that coming together for worship was safe.
He said: “I have not decided that all churches must immediately open or that it is safe for them to do so, or even that no restrictions at all are justified.
“All I have decided is that the regulations which are challenged in this petition went further than they were lawfully able to do, in the circumstances which existed when they were made.”