She questioned how his decision could be described as reasonable when it was largely based on advice from inside the UK Government and groups “hostile” to the GRR Bill.
“He can’t just close his eyes to one side of the argument. There would be no point in imposing a duty on him if that was acceptable,” Ms Bain told judge Lady Haldane.
The Bill is intended to make it simpler and quicker for a person to obtain a gender recognition certificate (GRC), changing their sex in the eyes of the law.
Under the current 2004 UK law, obtaining a GRC requires a medical diagnosis of gender dysphoria, living in an acquired gender for two years, and a minimum age is 18.
The Holyrood Bill would replace medical diagnosis with self-declaration, or self-ID, cut the two year period to three to six months, and lower the minimum age to 16.
Mr Jack used an unprecedented order under Section 35 of the Scotland Act to stop the GRR BIll becoming law after MSPs passed it by 86 to 39 in December with cross-party support.
He said the Bill, although within Holyrood’s competence, could nevertheless have adverse effects on the operation of UK-wide reserved law, notably equality law.
He said the Bill would create two different parallel systems for GRCs, one of which would only have effect in Scotland, and one which had effect UK-wide.
It meant someone could be one legal sex in Scotland and another in England and Wales.
Mr Jack suggested tax and benefit IT systems may not be able to cope with that.
He also said the Bill would remove safeguards for women and girls, and that it might attract fraudulent applications and be exploited by sexual predators.
On the opening morning of a scheduled three -day hearing at the Court of Session, Ms Bain said Scottish ministers regarded Mr Jack’s decision-making as unlawful, irrational and unreasonable and the Section 35 order should therefore be “reduced”, or annulled.
She said the court had a “constitutional duty” to review the use of the Section 35 Order, which was intended to be a “long stop” by the architects of the 1998 Scotland Act.
She argued that Mr Jack had made it unlawfully because of a “policy disagreement”, which was never the intention.
She said if the UK government was successful in the civil case, the Scottish Secretary “could veto practically any act of the Scottish Parliament having an impact on reserved matters because he disagreed with it on policy grounds”.
She said: “That would be tantamount to the Scottish Parliament being able to legislate only insofar as the UK executive consented.”
The court heard that a Section 35 Order was designed to be “narrowly construed” and “tightly controlled” and should only be used in very specific circumstances as a “last resort”.
She said the Order had to meet three conditions to be lawful – it had to modify reserved law, there had to be reasonable grounds for believing it would have adverse effects on the operation of reserved law, and it had to provide reasons for its use.
She said it failed on all three points and should therefore be reduced/
She argued Mr Jack made two “material errors of law”, as nothing in the GRR Bill modified he law as it applies to reserved matters, notably Section 9 of the 2004 Gender Recognition Act which deals with GRCs, and nor does it have an “adverse effect” on the operation of the law as it applies to reserved matters.
The Lord Advocate told the court that as the Bill would only change the process for getting a GRC, not the actual effect of the GRC itself, there was no impact on equalities laws.
She said the reasons given by the UK government for the order were “insufficient in law”.
Ms Bain also questioned the reasons Mr Jack included in the order.
She said she understood HMRC IT systems could cope with people having different legal sexes on different sides of the border, and it was a challenge to understand Mr Jack’s argument.
She said it was suprising that the UK Government appeared to be arguing the Bill represented an insurmountable problem for its software engineers.
She said it was for the Scottish Secretary to explain his reasons for his IT concerns not for Scottish ministers “to work out what he was on about”.
Ms Bain also said Mr Jack’s decision had been irreational and unreasonable, as he had failed to familiarise himself with available evidence in a balanced way.
Most of his advice came from the Equality Hub within the Cabinet Office, meaning it was one arm of the UK government advising another.
Mr Jack had also considered seven letters from outside bodies, but six were from “hostile” groups known to oppose the GRR Bill.
Moreover, the one letter which was not hostile, from a UN expert, had told him there was no international evidence to support his concerns about sexual predators.
Yet Mr Jack had failed to explain how he came to the opposite conclusion.