A Scottish judge has rejected a bid to have Boris Johnson's plan to shut down parliament ahead of Brexit declared illegal.
The case was brought to the Court of Session in Edinburgh by a cross-party group of 75 parliamentarians, who argued the PM had exceeded his powers.
But Lord Doherty ruled on Wednesday that the issue was for politicians and voters to judge, and not the courts.
He said there had been no contravention of the law by the UK government.
The group of MPs and peers behind the legal challenge, who are headed by SNP MP Joanna Cherry and Liberal Democrat leader Jo Swinson, will have their appeal against the ruling heard by three Inner House judges on Thursday.
The prime minister announced on 28 August he wanted to shut down Parliament, a process known as proroguing, for five weeks ahead of a Queen's Speech on 14 October.
His political opponents argue Mr Johnson's aim is to avoid parliamentary scrutiny and to stop them passing legislation that would prevent the UK leaving the European Union without a deal on 31 October.
Seems we have lost #Cherrycase to stop #prorogation at 1st instance. Judge rules court can’t review exercise of prerogative power to #prorogue. We thinks he’s erred in law on this point & others & will seek to appeal immediately #Brexit #StopTheCoup— Joanna Cherry QC MP (@joannaccherry) September 4, 2019
The UK government insists this is not the case, and says proroguing Parliament will allow Mr Johnson to set out his legislative plans in the Queen's Speech while still allowing sufficient time for MPs to debate Brexit.
In his ruling, Lord Doherty said the decision to prorogue parliament was justiciable - a matter for the courts - in some circumstances but not in others, depending on the context.
But he said he had not been persuaded after hearing legal arguments from both sides on Tuesday that the case before him was justiciable.
He added: "In my view, the advice given in relation to the prorogation decision is a matter involving high policy and political judgement.
"This is political territory and decision making which cannot be measured against legal standards, but only by political judgements.
"Accountability for the advice is to parliament, and ultimately the electorate - not to the courts."
Lord Doherty also said it was opinion that there had been "no contravention of the rule of law" by the prime minister.
He said: "The power to prorogue is a prerogative power and the prime minister had the vires (powers) to advise the sovereign as to its exercise."
The parliamentarians were supported in their legal challenge by Jolyon Maugham of the Good Law Project, who said: "The idea that if the prime minister suspends Parliament the courts can't get involved looses some ugly demons.
"If he can do it for 34 days, why not 34 weeks or 34 months? Where does the political power end? It is not the law as I understand it."
It emerged during Tuesday's hearing that Mr Johnson appears to have approved a plan to shut down the UK Parliament two weeks before publicly announcing it.
The Court of Session heard that the prime minister was sent a note on 15 August asking if he wanted to prorogue parliament from mid-September. A tick and the word "yes" was written on the document.
A lawyer acting for the BBC asked the court to release the documents in the interests of open justice. The appeal hearing will consider the request.
Responding to Lord Doherty's ruling, a UK government spokesman said: "As we have set out, the government needs to bring forward a strong domestic legislative agenda - proroguing Parliament is the legal and necessary way of delivering this.
"We welcome the court's decision and hope that those seeking to use the judiciary to frustrate the government take note and withdraw their cases."
What other legal challenges is the government facing?
On Thursday, the High Court in England will consider a judicial review request from Gina Miller, the businesswoman who successfully challenged the government over the triggering of the Article 50 process to start the Brexit countdown.
Ms Miller, who has been joined by former Prime Minister John Major, wants to challenge Mr Johnson's suspension of parliament.
And in Belfast, a judicial review against the government by a campaigner arguing that no deal could jeopardise the Northern Ireland peace process is scheduled for 16 September.