People aged 16 and 17 to be allowed to change gender
Young people aged 16 and 17 will be allowed to change their legal gender after the Scottish government rejected moves to keep the minimum age at 18.
Some SNP MSPs were among those who argued that 16 is too young to make such a "profound change".
But the government said lowering the age was in keeping with other rights and responsibilities people gain at 16. 
It came during a marathon debate on controversial plans to make it easier for trans people to change gender. 
Scottish Parliament was due to discuss and vote on more than 150 proposed amendments to reforms of the Gender Recognition Act on Tuesday ahead of the final vote on Wednesday.
But it had only dealt with about 64 of the amendments by 23:00, with the session finally finishing shortly after midnight when the lights in the Holyrood chamber - which are on a timer - went out.
remaining amendments resumed on Wednesday afternoon. It is not yet clear whether the final vote will have to be delayed. 
Scottish Conservatives have accused the government of attempting to rush the reforms through before Christmas in an attempt to avoid proper scrutiny.
Parliament had earlier been suspended for about half an hour when protesters shouted "shame on you all" and "there is no democracy here" from the public gallery as MSPs voted against a move to make it harder for sex offenders to change gender. 
Members of the public were later allowed back into the galleries, with MSPs describing the decision to remove them as "a disproportionate response" to the heckling.
Protestors hit out at MSPs voting on gender recognition legislation
government wants to make it easier for trans people to obtain a Gender Recognition Certificate (GRC), which changes the gender recorded on their birth certificate. 
roposals will: 
Efforts by some MSPs to keep the minimum age at 18 were voted down, with Social Justice Secretary Shona Robison saying that 16-year-olds have the right to vote in Scottish Parliament elections, leave home and get married.
However the government backed other amendments aimed at ensuring young people understand the process and receive appropriate support.
Ms Robison also insisted that "trans rights are not in competition with women's rights", and the proposals would be a "significant step forward in creating a more equal Scotland, where trans people feel valued, included and empowered."
Anyone who does obtain a GRC will need to live as their acquired gender for the rest of their life and could face prosecution if they do not - although it will be possible to detransition by going through the declaration process again. 
unishment for anyone who fraudulently obtains a GRC in an attempt to abuse the system could be up to two years in prison and an unlimited fine.
Opponents fear the proposals could pose a danger to women and girls, particularly around the provision of single-sex spaces.
Conservative MSP Russell Findlay tabled an amendment that sought to prevent convicted sex offenders being allowed to change their gender.
mendment was defeated by 59 votes to 64 with two abstentions - sparking angry scenes in the gallery.
However, the government backed another amendment by SNP MSP Gillian Martin that would mean anyone convicted of a sexual offence who wants to apply for a GRC will need to be fully risk assessed. 
If the risk is thought to be too high, their application could be refused. 
It follows concerns that predatory men could attempt to change their gender to gain access to female prisons. 
Seven SNP MSPs voted against the legislation at an earlier stage in the process - including former community safety minister Ash Regan, who resigned ahead of the first parliamentary vote - while two others abstained.
Ms Regan, who has said she will not back the government's bill, spoke during Tuesday's debate to criticise the lowering of the minimum age to 16, saying she believed it was too young for someone to make such a "very profound change".
SNP MSP Kenny Gibson also argued that keeping the age limit at 18 would give young people "time and space to grow" and be better prepared to take the "right decision". 
gan with apparent attempts from the Scottish Conservatives to delay proceedings by tabling four separate amendments to the parliamentary agenda. 
Despite the heated debate around the bill, it will almost certainly pass into law in a final vote - which is currently scheduled for Wednesday - given the wide support within the SNP, Greens, Labour and Liberal Democrats.
By Kirsten Campbell, BBC Scotland political correspondent
Lights go out in Holyrood chamber
As the clock approached midnight MSPs were warned the lights would go out automatically. By then some were beginning to mutiny. 
Could the Scottish Parliament seriously continue to call itself family friendly when politicians were being asked to consider amendments to legislation in the wee small hours of the morning? 
Security staff, catering staff, Parliament clerks all stuck at work well after their usual finish times, because the government wants the Gender Recognition Reform bill to be passed before Christmas.
At lunchtime on Tuesday,  MSPs were showing each other the snacks they'd packed to keep themselves going.
As the points of order mounted, there were mutterings of filibustering, and the Labour business manager Neil Bibby was applauded when he accused the Conservatives of time-wasting. 
Delays were compounded when the Tories insisted on pushing every amendment to a vote, even when its proposer didn't want to move it and the result was a foregone conclusion. 
When the Scottish Parliament was established, the idea was that it would be more family friendly than Westminster, with more standard office hours. 
In practice, that convention is often ripped up at the end of term, when there's a last minute rush to pass legislation before the start of a recess. 
Questions are being asked about whether such a late sitting was really necessary in this case. MSPs are due to finish up for Christmas at lunchtime on Thursday. The afternoon is free. 