The Scottish Parliament has passed legislation which aims to make it easier for transgender people to change their legally recognised gender.
It comes after three days of consideration of amendments to the Gender Recognition Reform Bill at Holyrood.
MSPs addressed 153 amendments that had been lodged at stage three of the Bill, having sat beyond midnight at the end of a marathon session on Tuesday.
Passing of the Bill draws to an end the parliamentary wrangling over the proposals, which have been contested fiercely by opponents of the legislation.
Campaign groups have warned that the reforms – which seek to make the process for people to obtain a gender recognition certificate easier – could risk the safety of women and girls.
However, supporters of the changes insist that it is about simplifying the process and removing hurdles within the current requirements.
Under the reforms, the age limit for applications for a gender recognition certificate will be lowered from 18 to 16.
A requirement for a medial report, including a diagnosis of gender diagnosis, will be dropped.
Applicants for a certificate will also now be required to live in their acquired gender for three months (six months for 16 and 17-year-olds) – down from the current requirement of two years.
An amendment submitted by SNP MSP Gillian Martin to ensure that anyone subject to a sexual harm prevention order, or a sexual offences prevention order, cannot seek a gender recognition certificate, is also being implemented having been accepted by MSPs.
Scottish Greens MSP Maggie Chapman hailed the result as a “historic day for equality”.
She added: “Trans rights are human rights and I am proud that our parliament has voted to bring Scotland closer in line with best international practice while improving the lives of our trans siblings.
“Self-identification, including for 16 and 17 year olds, is a crucial reform. And it is because it is a key part of the Bute House Agreement that the Scottish Greens negotiated with the Scottish Government, that it is now a reality. And I am very pleased that it is.
“The last three days of debate have shown the best and worst of our Parliament. But today isn’t about party politics. It is about the future and the progressive and inclusive society that we want to build.”
The new law has prompted rebellions across the chamber, with nine SNP MSPs voting against, including former minister Ash Regan.
Regan was joined by Michelle Thomson, Stephanie Callaghan, Annabelle Ewing, Fergus Ewing, Kenneth Gibson, John Mason, Jim Fairlie and Ruth Maguire.
Meanwhile, two Labour MSPs – Carol Mochan and Claire Baker – voted against the party whip, while it is understood some Labour opponents to the Bill were allowed to miss the vote.
Mochan and Baker both hold frontbench positions within the Labour Party which they will now be expected to quit.
For the Tories, Jamie Greene and former leader Jackson Carlaw voted in favour of the reforms.
Hamilton said the Bill “has shown this Parliament at its worst”.
She added: “In the rush to make the process a little easier for trans people, the Government is making it easier for criminal men to attack women. That’s the problem here.”
Hamilton said the Bill – which she claimed would be a “legacy issue for the First Minister” – would “let criminal men exploit the system” and put women at risk in single-sex spaces.
The Equality Act features exemptions for single-sex spaces where trans people can be excluded in certain circumstances – exemptions Robison has said will not change.
Hamilton went on to claim that “society as a whole” is at risk from the Bill, adding: “While most of us across Scotland are good, decent, reasonable people, rapists are not, sex offenders are not, it is ignorant in the extreme to believe that they will not take advantage of loopholes that are ripe for exploitation.”
The process could still be blocked if the Scottish Government’s Westminster equivalents exercise their powers to prevent the laws “having “an adverse effect on the operation of the law as it applies to reserved matters”.
The secretary of state for Scotland, Alister Jack, said the “ramifications” of the legislation for UK laws would have to be explored and did not rule out an order stopping the Bill from receiving royal assent.
The UK equalities minister, Kemi Badenoch, previously raised concerns the bill passing could create a “divergence” between laws in Scotland and England.
Labour’s Pam Duncan-Glancy said the legislation provides MSPs with “one of those rare moments… where we all have a real opportunity to improve lives and directly tackle inequality”.
She said the Bill will help “society to accept them (trans people) and to support them to be their best selves, without barriers or additional costs or medicalisation”.
She insisted: “I believe strongly the reform we will vote for today has been a long time coming, and that is why changing the current onerous, lengthy and invasive process of legal gender recognition has always been so important to me.”
STV News is now on WhatsApp
Get all the latest news from around the countryFollow STV News
Follow STV News on WhatsApp
Scan the QR code on your mobile device for all the latest news from around the country