Humza Yousaf has lost his high-profile court case over Holyrood’s gender reforms.

The First Minister had tried to stop the UK Government from vetoing legislation intended to make it quicker and simpler for people to change their legal sex in Scotland.

However a Court of Session judge today ruled the UK Government had been within its rights to block the Gender Recognition Reform (Scotland) Bill, despite it being approved by MSPs.

Lady Haldane's 65-page opinion is a blow to Mr Yousaf's authority and that of his deputy, Shona Robison, who led the legisation through Holyrood in her previous role as social justice secretary.

It now leaves Mr Yousaf facing a difficult decision on whether to appeal the ruling to the Court's Inner House, and then potentially to the UK Supreme Court.

The case has already cost the Scottish Government almost £230,000 in legal fees, and more appeals could add to that substantially, leading to accusations of wasting public money.

However Mr Yousaf’s partners in the coalition government, the Scottish Greens, are keen that the Bill becomes law and will put pressure on him to continue the legal fight. 

Gender reform based on the Bill is part of the Bute House Agreement between the two parties. 

But Mr Yousaf will also be mindful that many of his own MPs and MSPs - and most Scots, according to polls - oppose elements of the Bill and would prefer it to remain frozen.

MSPs passed the GRR Bill in December last year by 86 votes to 39 on a cross-party basis.

Its aim is to speed up and simplify the process for a trans person to change their gender in the eyes of the law by obtaining a gender recognition certificate (GRC).

Under the current UK-wide system, this takes at least two years, involves a medical diagnosis of gender dysphoria and is available only to those aged 18 and above.

The GRR Bill would cut the waiting time to three to six months, replace a medical diagnosis with self-declaration (Self-ID) and reduce the age threshold to 16 in Scotland.

But before it could become law, Tory Scottish Secretary Alister Jack vetoed it in January by using an unprecedented order under Section 35 of the 1998 Scotland Act that underpins devolution.

He argued that although the subject matter was within Holyrood’s powers, the Bill cut across UK-wide equality law and could pose a risk to single-sex spaces.

Nicola Sturgeon, the First Minister at the time, called it a full-frontal assault on devolution.

Running for the SNP leadership in the spring, Mr Yousaf said that he would challenge the Setion 35 Order if he became First Minister and duly launched a judicial review in April.

In August, he told an audience on the Edinburgh Fringe that the challenge was more about stopping Westminster over-ruling Holyrood than the Bill per se.

“It’s not actually about the legislation itself. It’s the principle," he said.

In two days of hearings in September, the Scottish Government argued Mr Jack’s decision to use a Section 35 order had been unlawful, irrational and based on an error of law.

Mr Yousaf’s top law officer, the Lord Advocate Dorothy Bain KC, also argued Mr Jack’s decision had been based on inadequate and irrelevant considerations.

She said the veto had been used because of a “policy disagreement” between London and Edinburgh rather than because of a genuine legal concern. 

The UK Government said Mr Jack had been legally entitled to act as he did, had acted in good faith, and dismissed Ms Bain’s “policy disagreement” argument as a “red herring”.

The Scottish Government is now expected to consider Lady Haldane's judgment in detail before deciding whether to appeal.

It has 21 days in which to make up its mind.

Mr Jack said: "I welcome the Court’s judgment, which upholds my decision to prevent the Scottish Government’s gender recognition legislation from becoming law.

“I was clear that this legislation would have had adverse effects on the operation of the law as it applies to reserved matters, including on important Great Britain-wide equality protections. 

“Following this latest Court defeat for the Scottish Government, their ministers need to stop wasting taxpayers’ money pursuing needless legal action and focus on the real issues which matter to people in Scotland - such as growing the economy and cutting waiting lists.” 

Colin Macfarlane, director of nations at LGBTQ+ charity Stonewall, said: “We’re disappointed that the Court of Session in Scotland has found in favour of the UK Government’s unprecedented decision to use Section 35 to block the Gender Recognition Reform Bill from royal assent.

“This Bill was one of the most debated in the Scottish Parliament’s history and was passed by a resounding majority of MSPs drawn from all major Scottish parties.

“This unfortunately means more uncertainty for trans people in Scotland, who will now be waiting once again, to see whether they will be able to have their gender legally recognised through a process that is in line with leading nations like Ireland, Canada and New Zealand.

“Whatever happens next in discussions with the UK and Scottish Governments on this matter, Stonewall will continue to press all administrations to make progress on LGBTQ+ rights in line with leading international practice.”