An East Kilbride police officer was spat on and subjected to racist abuse by a man he was trying to help.
PC Mehmet Uslu and a colleague had offered to take Robert Whitehill to hospital for checks.
But Hamilton Sheriff Court heard that the 24-year-old suddenly became aggressive.
Whitehill, a prisoner, appeared via videolink from Barlinnie Prison.
He admitted racially-aggravated assaults on the officer outside East Kilbride police station on October 21.
Chloe O'Hara, prosecuting, said the officers met Whitehill in the police station car park around 10.20pm.
He said he had an alcohol addiction and had been at hospital earlier.
The officers were concerned for his welfare and said they would take him back to hospital to be checked over.
Ms O'Hara told the court: "Whitehill was placed in the rear of the police vehicle, but suddenly became aggressive, saying he didn't want to go to the hospital.
"He made attempts to open the door and get out, and the officers tried to calm him down.
"The accused then turned towards PC Uslu and spat at him. It landed on his arm.
"He then tried to headbutt him, but the officer managed to evade this.
"During this time the accused called the officer a black ba***rd."
Defence agent Andy Thomson said Whitehill, who admitted previous convictions, has "significant" mental health issues.
Sheriff Andrew McIntyre deferred sentence until next month for a criminal justice social work report.
Whitehill has been in custody since his arrest and remains behind bars.
**Don't miss the latest headlines from around Lanarkshire. Sign up to our newsletters here.
And did yo u know Lanarkshire Live is on Facebook? Head over to our page and give us a share and like.