Scottish judges are considering whether a court can sign a Brexit extension letter on behalf of the government.
The Inner House of the Court of Session, Scotland's highest court, is being asked to act directly if Boris Johnson refuses to request a delay.
The letter is a key provision of what is known as the Benn Act, by which MPs hope to prevent a no-deal Brexit.
The court also heard an appeal against a ruling that Mr Johnson can be trusted to apply the law.
Lord Pentland said following an earlier hearing that there could be "no doubt" that the prime minister had agreed to abide by the law.
As a result, he said there was no need for "coercive orders" against the UK government or against the prime minister.
And he said it would be "destructive of one of the core principles of constitutional propriety and of the mutual trust that is the bedrock of the relationship between the court and the Crown" if Mr Johnson reneged on his assurances to the court.
But speaking for the petitioners - businessman Dale Vince, QC Jolyon Maugham and SNP MP Joanna Cherry - Aidan O'Neill QC said it appeared Mr Johnson might still intend to get around the intention of the Benn Act and take the UK out of the EU without a deal.
During the hearing on Tuesday, he cited recent articles quoting Number 10 sources which predicted that talks with the EU could break down this week. He said it was clear the government's policy was to "undermine" and "frustrate" the legislation - which requires Mr Johnson to request a Brexit extension if no deal is struck by 19 October.
The petitioners want the court to use its "nobile officium" power to effectively sign a letter to European leaders on behalf of Mr Johnson, if the prime minister refuses to do so himself.
Mr O'Neill said this could be necessary to "enforce" an act of the Westminster parliament, rather than be a case of the court delving into foreign affairs.
However, Andrew Webster QC, for the UK government, argued that in the current "delicate times", international relations should be left to ministers rather than the courts.
He said the government was entitled to promote its own policies - provided it does so "lawfully" and without "frustrating" the legislation passed by opposition MPs.
The case will be decided by a panel of three senior judges - although one, Lord Carloway, discussed whether the court could delay a decision on the "nobile officium" until after the 19 October deadline, when the political position would be clearer.
A judgement will be issued on Wednesday.
What is the nobile officium?
The procedure of petitioning the nobile officium is unique to Scots law, but is far from being a forgotten backwater of the legal system.
Its name is a Latin term meaning the "noble office".
The procedure offers the opportunity to provide a remedy in a legal dispute where none exists.
In other words, it can plug any gap in the law or offer mitigation if the law, when applied, would be seen to be too strict.
In this case, it would see an official of the court sign a letter to the EU requesting a Brexit extension, as set out in the Benn Act, should the prime minister refuse to.
What is the 'Benn Act'?
Last month, MPs passed a law - the European Union (Withdrawal) (No. 2) Act 2019 which was introduced by Labour's Hilary Benn - designed to stop Boris Johnson pushing through a no-deal Brexit on 31 October.
Under the law, MPs Mr Johnson is required to request a three-month Brexit delay by 19 October.
There are two scenarios in which Mr Johnson would not have to request an extension:
- MPs approve a Brexit deal in another meaningful vote
- MPs vote in favour of leaving the EU without a deal
In either of these scenarios, Mr Benn's law would not force any Brexit extension to be requested.