MSPs have given their initial backing to the Scottish government's new hate crime laws after ministers promised to make changes to the controversial plans. What will the bill do to protect victims of hate crime, and why has it proved contentious?
What is hate crime?
A hate crime is a criminal offence that is based on prejudice against a specific group of people - for example attacking someone because of their religion or the colour of their skin.
Scotland already has various laws in place that offer additional protection to people from crimes based on their disability, race, religion, sexual orientation and transgender identity.
It means that crimes can be treated more seriously by the courts if the offender has shown "malice and ill-will" towards the victim based on their membership - or association with - one of the protected groups.
What does the Scottish government want to do?
The government asked a senior judge, Lord Bracadale, to examine all of the country's existing hate crime legislation to make sure it was still fit for purpose in the 21st Century.
It then introduced the Hate Crime and Public Order bill to the Scottish Parliament in response to his recommendations.
The bill adds hate crime based on a person's age to the list of protected groups, with hatred based on someone's sex potentially to be added in the future.
It aims to simplify and clarify the law by bringing together the various existing hate crime laws into a single piece of legislation.
And it creates a new crime of "stirring up hatred" against the protected groups - which is defined as "behaving in a threatening or abusive manner, or communicating threatening or abusive material to another person".
The bill originally said that this could be "with the intention" of stirring up hatred against someone from a protected group, or "where it is a likely consequence that hatred will be stirred up against such a group".
However, the Scottish government has now said that the bill will be amended to ensure that only people who intended to stir up hatred will be prosecuted.
The bill also formally abolishes the offence of blasphemy - which has not been prosecuted in Scotland for more than 175 years.
The government says the bill "makes it clear to victims, perpetrators, and communities and to wider society that offences motivated by prejudice will be treated more seriously and will not be tolerated by society".
Why are some people not happy?
Serious concerns have been raised about the potential impact on freedom of speech, with opponents arguing that the full implications of the proposed law have not been thought through.
While supporting the principle of protecting people from prejudice, they argue that the definition of "stirring up hatred" is too vague and open to interpretation.
There have been suggestions, for example, that the bill could lead to author JK Rowling facing a seven-year prison sentence for expressing her concerns about the impact of trans rights on women.
And opponents say comedians could potentially be prosecuted for making a joke about a "Scotsman, and Englishman and an Irishman" walking into a bar.
There have also been claims from the Catholic Church that the new law could make it illegal for people to oppose same-sex marriage or increased transgender rights on religious grounds.
And there were even concerns that proposed laws on possessing "inflammatory material" could potentially lead to libraries and bookshops being prosecuted for stocking books that are deemed to be offensive.
This section of the bill would have covered people who "have in their possession threatening, abusive or insulting material with a view to communicating the material to another person".
However, the government has bowed to pressure and agreed to remove this section entirely.
Many opponents have drawn parallels with the highly-controversial Offensive Behaviour at Football Act, which was eventually repealed by the Scottish Parliament.
And the Scottish Police Federation has warned that the proposals would force officers to "police what people think or feel" which it says would "devastate the legitimacy of the police in the eyes of the public".
How has the government responded?
The Scottish government announced on 23 September that it would change the bill in a bid to ease some of the concerns about its impact on freedom of speech.
Justice Secretary Humza Yousaf told the Scottish Parliament that the legislation would now only cover offences where the stirring up of hatred was intentional.
He said: "I want people across this chamber and across Scotland to come together so we can ensure hate crime law can deal with the problem of stirring up hatred in an effective and appropriate way.
"That is why I think it is important to put the concerns over the question of the operation of the new offences beyond doubt."
But some, including the Scottish Conservatives, have said the changes do not go far enough - and have called on Mr Yousaf to rip up the legislation and start again.
How big a problem is hate crime anyway?
Figures released in June showed that the number of people charged with hate crimes in Scotland has increased over the past year.
Racial offences remain the most commonly reported hate crime, with a total of 3,038 charges last year - an increase of 4% on the previous year, but still the second lowest since comparable records began in 2003/04 and 33% lower than the peak recorded in 2011/12.
The figures also showed that:
- The number of sexual orientation charges increased by 24% to 1,486
- There were 660 religiously aggravated charges, which was also an increase of 24%
- The number of disability aggravated charges increased by 29% to 387
- There were 41 charges reported with an aggravation of transgender identity, compared to 40 the previous year.
The increase in charges may suggest that victims have more confidence in coming forward - but many incidents still go unreported.
What happens next?
Members of Holyrood's justice committee were tasked with scrutinising the near 2,000 written views which were sent during a recent consultation period.
They penned a stage one report on the bill which said it should proceed through parliament - but only if further changes were made.
The government agreed to make additional alterations to the legislation, accepting the "overwhelming majority" of the committee's recommendations.
MSPs have now backed the "general principles" of the bill, meaning it has passed its first parliamentary hurdle - but many warned they would want to see further amendments made if it is to continue through Holyrood and become law.
The Hate Crime Bill will now return to the committee for even more amendments to be considered, before going back before MSPs for a final vote next year.