Members of the Scottish Parliament have voted to pass legislation to protect gay, trans and disabled people from hate crime.

The new law means targeting victims because of their sexual orientation, gender identity or disability will become an aggravating factor and is likely to lead to heavier sentences.

It is also hoped the legislation will encourage more victims of hate crimes to come forward.

The Sentencing of Offences Aggravated by Prejudice (Scotland) Bill was proposed by Patrick Harvie, a Scottish Green MSP who is openly gay.

Despite concerns from the Conservatives that it could create a “two-tier justice system”, the law was passed unanimously.

Scotland already took into account crimes motivated by religious or racial hatred, but the new law will bring it in line with the rest of the UK.

Mr Harvie said: “The issue of hate crime is one which reaches down into every community and affects real lives.

“Although this is a small step in the right direction, we should be glad we are able to take it.”

Speaking about his memories of being bullied at school for being gay, he said: “To even challenge it was to risk personal safety – and this in the supposedly protected environment of school.

“This hasn’t gone away in the rest of society. This kind of behaviour, which may be wrongly dismissed as playground banter, is deeply harmful criminal behaviour.”

He added that the law was no “silver bullet” but was a “necessary part of the overall picture” for tackling prejudice and hate crimes.

It is estimated that one in five lesbian and gay people have been the victim of a homophobic hate crime or incident in the last three years, while disabled people are thought to be four times more likely be assaulted than able-bodies people.