A judge has thrown out a legal challenge against the Scottish Government's definition of a woman in law.
The challenge from campaign group For Women Scotland related to statutory guidance produced by Scottish ministers around gender representation on public boards.
The campaign group won an appeal earlier this year, following which Scottish Ministers produced revised statutory guidance to the Gender Representation on Public Boards (Scotland) Act 2018.
However, the campaign group returned to court contending that the revised guidance was "unlawful".
They argued the definition of woman in the Equality Act 2010 is to be taken as a reference to "biological woman" and that any attempt to conflate that concept with that of a person who has an acquired gender of female in terms of a gender recognition certificate (GRC) issued under the Gender Recognition Act 2004 is "impermissible".
Issuing her decision on Tuesday, the judge, Lady Haldane, said that "at its heart, this petition is concerned with whether or not, as a matter of law, the definition of 'woman' in the 2010 Act includes those persons holding a GRC stating that their acquired gender, and thus their sex, is female."
She concluded that "sex" is not limited to biological or birth sex and that the revised guidance issued by the Scottish Government is lawful.
In her decision, Lady Haldane wrote: "I conclude that in this context, which is the meaning of sex for the purposes of the 2010 Act, 'sex' is not limited to biological or birth sex, but includes those in possession of a GRC obtained in accordance with the 2004 Act stating their acquired gender, and thus their sex.
"Such a conclusion does not offend against, or give rise to any conflict with, legislation where it is clear that 'sex' means biological sex."
The ruling comes days before next week's final vote on the Scottish Government's plans to reform the Gender Recognition Act.
The Gender Recognition Reform (Scotland) Bill, currently working its way through Holyrood, proposes to remove the requirement for a medical diagnosis of gender dysphoria as a condition of acquiring a gender recognition certificate.
Concerns have been raised about the impact the Bill could have on single-sex spaces, with some critics saying it could put women at risk - a charge the Scottish Government has repeatedly denied.
For Women Scotland said that are "hugely disappointed" at the ruling.
In a statement they said: "At first reading this seems disastrous for women who are seemingly now no longer recognised in law as a sex-class, with distinct requirements of our own.
"We are obviously still analysing the decision and will consider if any further legal action is appropriate in due course.
"There are clear ramifications for the Gender Recognition Reform Bill currently before Parliament and we hope some time will be allowed for MSPs to digest the ruling and its consequences.
"It is now beyond doubt that the Bill is not a simple administration change but does have a wider impact on society.
"Many thanks to all those who donated and supported us this far, we will all keep fighting."
A Scottish Government spokesman said: "We are pleased to note the outcome of this challenge."