A pensioner who sent abusive emails to Labour MSP Anas Sarwar has been fined.
In one of the messages, Donald Brown, 72, told the politician to "go back to Pakistan because you're probably happier amongst your own kind".
In another, he wrote that if Mr Sarwar was not happy living in Scotland, he should "buy some tickets and go back to whatever... country you came from".
At Dumfries Sheriff Court, Brown was ordered to pay £400 after he admitted sending racially offensive messages.
The messages were sent early last year, after Mr Sarwar claimed a Scottish Labour councillor told him "Scotland wouldn't vote for a brown Muslim Paki".
Mr Sarwar then launched a cross-party group on Islamophobia at Holyrood, with the aim of rooting out institutionalised racism in Scotland.
Brown, who is retired and lives in Dumfries, emailed Mr Sarwar on 29 January 2018 - the day the politician's claims of racism first hit the headlines.
Using strong language, he suggested the former Scottish Labour leadership candidate join the SNP.
He added: "You know as well as me that the Labour party in Scotland would choose a white guy over you every time. I'm sorry to tell you this but it's true."
Brown sent a second email on 10 February 2018, urging the politician to "grow up and stop worrying about the colour of your skin".
"If you are still not happy about the situation, why don't you join the SNP or as a last resort, buy some tickets for you and your family and go back to Pakistan because you're probably happier amongst your own kind," he added.
In a third email sent on 8 March 2018, he asks Mr Sarwar to "stop playing the race card".
He added: "If you don't like living in Scotland because you feel that you are being picked on, feel free to buy some tickets and go back to whatever... country you came from. People are getting a bit fed up listening to your racist comments."
The court heard that Mr Sarwar decided to call the police after receiving the third email.
Brown's defence solicitor told the court her client apologised for his behaviour.
She added that Brown had "quite strong views" on Islam but he accepted he should not have sent the emails to Mr Sarwar.
He was diagnosed with depression during the period the emails were sent, after undergoing heart surgery.
She said Brown had taken a keen interest in politics and would regularly contact politicians from different parties to discuss various issues, but he has now stopped emailing any politicians.
Sheriff George Jamieson said he would reduce the fine of £600 to £400 as Brown plead guilty at the earliest opportunity.
Mr Sarwar declined to comment on the case.