The wider issue of gender has provoked years of debate in Scotland.

This includes arguments about the case of a transgender rapist known as Isla Bryson and an attempt by politicians in Edinburgh – ultimately blocked by Westminster – to make it easier to legally change gender.

A pivotal moment came in April when the UK Supreme Court clarified the law on gender, unanimously ruling that a woman is defined by biological sex under the Equality Act.

“The concept of sex is binary, a person is either a woman or a man,” wrote the judges, adding that “the ordinary meaning of those plain and unambiguous words” was self-explanatory and required “no further explanation”.

The 88-page judgment was a repudiation of the SNP’s interpretation of the law.

The Scottish government responded that it had acted in good faith by arguing in court that trans women were women.

Ms Peggie has since called on NHS Fife to respond to the Supreme Court by acting immediately to “stop permitting any man who identifies as a woman” access to female-only spaces.

NHS Fife says work is underway to “identify areas where any adaptations may be required and schedule any work that may be necessary,” as a result of the judgment.

It added that it was waiting to review a new code of practice expected to be issued by the Equality and Human Rights Commission (EHRC), which advises public bodies on the law.

In a statement, the EHRC said it was “currently working at pace” on the new advice but it added that organisations should “comply with the law” now by “looking at what changes, if any, need to be made to their policies and practices”.

The Scottish government says it “accepts the Supreme Court ruling” adding that “detailed work that is necessary as a consequence” is ongoing.