LONDON (AP) — A plan by Scotland’s government to make it easier for people to change gender for legal purposes has sparked acrimonious debate, with lawmakers arguing inside the Edinburgh parliament and rival groups of protesters demonstrating outside.

A bill introduced by the Scottish National Party-led government would allow people to transition by self-declaration, removing the need for a medical diagnosis of gender dysphoria. The government says it a simple step that will improve the lives of transgender people by allowing them to get official documents that correspond with their gender identity.

Opponents, including “Harry Potter” author J.K. Rowling, claim the simplified procedure risks allowing predatory men to gain access to spaces intended for women, such as shelters for domestic abuse survivors.

The Scottish parliament is set to resume debating the bill Wednesday after a session the previous day lasted until midnight. A final vote is scheduled, though multiple amendments mean it may be delayed.

Tuesday’s debate descended into acrimony, with spectators shouting “Shame on you” after lawmakers defeated an amendment that aimed to prevent convicted sex offenders from obtaining a gender recognition certificate.

Legislators also defeated an amendment that would have set the minimum age for gender transition at 18 rather than 16.

Supporters of transgender rights demonstrated outside the parliament building in Edinburgh to urge lawmakers to support the bill. One of them, Beth Douglas, said the bill under debate would allow people to have birth certificates — and eventually their death certificates — that match their gender identity.

“There will be a day for everyone when we are issued a death certificate,” said Douglas, who runs an LGBT+ group. “When that happens for me, I want that death certificate to be in the right gender. I would like to rest in peace and die in dignity.”

At a separate demonstration by opponents, Rowling’s husband read out a message from the author, in which she branded the bill “the single biggest rollback of women’s rights in our lifetimes.”

The bill is likely to pass, though it is opposed by the opposition Conservatives and by some in the governing SNP.

Joanna Cherry, an SNP lawmaker in the U.K. Parliament, said the law “gives any man the right to self-identify as a woman after three months of living as a woman … with minimal safeguards.”

The law will set Scotland apart from the rest of the United Kingdom, where a gender dysphoria diagnosis is needed before individuals can have the gender designation on their identity documents changed.

Under the Scottish legislation, trans people would be allowed to have the markers revised if they have spent three months living with a different expressed gender, six months for people ages 16 and 17. The current period is two years.

Opponents say the legal change could endanger women and girls, who currently are guaranteed access to single-sex spaces such as changing rooms and shelters.

Reem Alsalem, the United Nations’ special rapporteur on violence against women and girls, has said the changes could allow men to take advantage of loopholes “to get into women’s spaces and have access to women.”

The Scottish government says trans people can still be excluded from single-sex spaces under existing legislation.

“Trans rights are not in competition with women’s rights,” said Social Justice Secretary Shona Robinson.

Spain’s parliament on Wednesday held another debate on a similar bill that has sparked a fierce debate inside the ruling left-wing coalition, where many feminists are against self-determination. If passed into law, people as young as 16 could change their gender freely and those as young as 12 could do so with a judge’s authorization

___

Associated Press writer Joseph Wilson in Barcelona contributed to this story.