A Scottish judge is being asked to consider whether Boris Johnson could be jailed if he takes the UK out of the EU without a deal.
A legal challenge is to be heard at the Court of Session about whether the prime minister could be forced to delay Brexit if no exit deal is agreed.
However, Mr Johnson has said he would rather be “dead in a ditch” than ask European leaders for another extension.
The court case seeks to establish what might happen if he refuses to act.
This could even include the court effectively signing a letter to European leaders on behalf of Mr Johnson, asking for a fresh extension.
The UK government has insisted it is focused on sealing a deal with the EU to ensure the UK can leave by 31 October, the current deadline, but says a no-deal exit is the only other alternative.
The legal action has been initiated by businessman Dale Vince, QC Jo Maugham and SNP MP Joanna Cherry.
They want the Court of Session to rule on the extent to which Mr Johnson is bound by the legislation passed by opposition MPs – the “Benn Act”, which requires the government to request an extension to the Brexit deadline if a deal has not been signed off by parliament by 19 October.
Lord Pentland will hear arguments on Friday about what the consequences of the prime minister not doing this would be, with the petitioners suggesting “penalties including fine and imprisonment” could be applicable.
The judge will rule on this initial part of the case on Monday, after which a panel of Inner House judges will consider whether the court could use its “nobile officium” power to effectively sign a letter to European leaders if Mr Johnson refuses to do so.
Mr Johnson has continued to insist that the UK will leave the EU by 31 October, and said he would “rather be dead in a ditch” than request a fresh delay.
He has repeatedly referred to the Benn Act as “the surrender bill”, saying it would “take away the power of this government, and the power of this country to decide how long it would remain in the EU, and give that power to the EU”.
And he said on Wednesday there was “no doubt” the only alternative to the fresh exit proposals his government has drawn up was to leave without a deal.
Why are there two parts to the case? BBC Scotland political correspondent Andrew Kerr explains
You can think of this as one train – but a part of that train is detaching and going down a slightly different track.
Under the Benn Act, Boris Johnson has to seek a Brexit extension if there isn’t a deal that’s been signed off by Parliament.
The case being heard today by Lord Pentland is about the remedies or punishments that could be inflicted on the prime minister if he doesn’t seek an extension – whether that is a fine or imprisonment.
Next week there’s this other case – the nobile officium case – which is about whether the court has the power to sign a letter in the absence of Boris Johnson requesting an extension, if he is refusing to do that.
That letter would be signed by the clerk of the court.
This all could be appealed at the Supreme Court with a decision there.
The government has said it will stick to the law but it wants to test the limit of what is lawfully required.
Foreign Secretary Dominic Raab meanwhile has suggested the government would “adhere to the law” but would “want to test to the limit what it actually lawfully requires”.
Prior to the hearing in Edinburgh, Ms Cherry said Mr Johnson “cannot be trusted”, and the court action was about “ensuring he abides by the law”.
She said: “If Boris Johnson tries to defy the law and defy both the Holyrood and Westminster parliaments by crashing out of the EU without a deal – then we are calling on the Scottish courts to uphold the law.
“Last week, the UK Supreme Court unanimously ruled that Johnson’s attempt to shut down Parliament was unlawful, void and of no effect. He must be reminded that he is not above the law.”