Scottish Labour MSP Anas Sarwar feared for his safety and that of his family after receiving racist emails, a court was told.

At Glasgow Sheriff Court on Tuesday, Alexander Agnew, 53, escaped a jail sentence after admitting to sending the abusive messages.

Sheriff Lindsay Wood ordered Agnew to perform 120 hours of unpaid work.

He also imposed a curfew - banning him from leaving his home between 9pm and 6.30am for the next eight months.

Sheriff Wood praised Mr Sarwar, who lost out in the Scottish Labour leadership contest to Richard Leonard following the resignation of Kezia Dugdale in 2017, before sentencing Agnew.

He told Agnew: "You had a drink and did things totally unacceptable to a man in the public, who is doing a good job.

"You had no business doing that and it was embarrassing some of the stuff you were putting out - you tried to be clever and it was anything but."

And the sheriff warned Agnew: "If you breach this order you will face me again."

Agnew sent eight emails in February last year, which included disturbing videos from a right-wing terrorist group.

One told Mr Sarwar that he was "no longer welcome" and another warned that his office would be torched.

Earlier this month, prosecutor Lucy Adams told the court that the emails had an impact on the life of Mr Sarwar.

She said: "Mr Sarwar perceived the content of the emails to be racist and sinister.

"He felt anxious and personally threatened as a result of receiving them, particularly after viewing the video.

"He feared for his safety and for that of his family, believing he had been targeted because of his race and his campaign against racial hatred."

Police seized the emails and sent them to the force's cybercrime unit.

The investigation found the emails all matched up with Agnew's mobile phone number and his partner's Penilee address in Glasgow.

Agnew was cautioned, charged and made no reply.

Miss Adams added: "He said he had no explanation and could not remember sending the emails as he was intoxicated at the time.

"He could recall sending the video attachment and confirmed his email access."

Defence lawyer Campbell Porter stated: "Mr Agnew has a drink problem and he apologises for his behaviour."