SCOTLAND’S highest civil court has rejected a legal bid that argued Boris Johnson’s new Brexit deal is unlawful, branding it "misconceived and unjustified".

Campaigner Jolyon Maugham QC had wanted the Court of Session in Edinburgh to suspend the agreement between the EU and UK on the basis that it “provides for Northern Ireland to form part of a separate customs territory to Great Britain”.

He was also seeking an interim interdict – similar to an injunction – to stop UK ministers from entering into such arrangements.

However, Judge Lord Pentland said Mr Maugham's legal argument was "at best a weak one".

In a written ruling, he said: "In the first place, the petition is of very doubtful competency.

"The orders sought would unquestionably interfere to a major extent with the proposed proceedings in Parliament.

"Suspension of the draft withdrawal agreement would mean that the motion for its approval could not realistically or properly go ahead as planned.

"I cannot see that it would be right for Parliament to be invited to consider a draft treaty which the court had suspended on the basis that it was unlawful.

"It is a cardinal principle of constitutional law that the courts should not intrude on the legitimate affairs and processes of Parliament."

Mr Maugham had argued the Prime Minister’s deal contravenes Section 55 of the Taxation (Cross-border Trade) Act 2018.

This states it is unlawful for the UK Government “to enter into arrangements under which Northern Ireland forms part of a separate customs territory to Great Britain", and was initially put forward by the Conservatives' right-wing group of MPs known as the European Research Group.

But Lord Pentland dismissed this argument, and said nothing had been placed before the court by way of evidence.

He also said he was not convinced there was any "genuine urgency such as to justify the granting of interim orders".

The judge said Mr Maugham's approach "fails to take account of the fact that the withdrawal agreement is at present still at the stage of being merely a draft instrument".

He said: "It requires to be ratified, both at UK and EU levels. These procedures should be allowed to be followed through in line with the appropriate processes in the UK Parliament and elsewhere."

He added: "For all these reasons, I conclude that the petitioner’s applications for interim orders are misconceived and unjustified."

Earlier, Aidan O’Neill QC, acting for Mr Maugham, had insisted the new Brexit deal is a "void agreement which has been presented publicly and to Parliament as if it were a valid agreement".

He said the legal reality is it would mean Northern Ireland remained part of the EU customs territory, and so the deal represents an "unlawful action on the part of the UK Government".

However, Gerry Moynihan QC, for the UK Government, described the legal action as a "manifest attempt to interfere with proceedings in Parliament", and “fundamentally incompetent”.

Legal advisers for Commons Speaker John Bercow also wrote to both parties to insist the “courts should not make any order which would inhibit the bringing of any matter before Parliament”.

It comes after the Prime Minister and European Commission President Jean-Claude Juncker announced the two sides had reached a Brexit deal on Thursday, ahead of a crucial EU summit in Brussels.

EU leaders then approved the deal, and MPs are expected to vote on it today.

Mr Johnson has insisted his agreement removes the "anti-democratic" Irish backstop, which aimed to avoid a hard border on the island of Ireland.

Meanwhile, the EU's chief negotiator Michel Barnier has said Northern Ireland would be part of the UK's customs territory, but would "remain an entry point" into the EU single market and aligned to some EU rules on goods.

In a statement after the court ruling, Mr Maugham said the decision to issue proceedings had had to be made quickly.

He said: "That was a difficult decision to make. It is difficult to move quickly and accurately and, the court has found, I got that decision wrong."