Police were forced to use pepper spray to bring a drunk man under control as he threw a defibrillator at ambulance staff trying to help him.
They had to use the Pava incapacitating spray on Lee Ellis as he went to punch them during the row in a Dewsbury car park.
Paramedics had rushed to the aid of the 33-year-old after discovering him lying unconscious in the road.
His solicitor explained that he had turned to drink after finding his friend dead in his flat.
Ellis pleaded guilty to being drunk and disorderly in public and resisting a constable in the execution of his duty.
Police attended Union Street near Dewsbury Railway Station on the evening of May 22 in response to members of an ambulance crew who had pressed their emergency button.
Alex Bozman, prosecuting, said: “They found him lying out cold in the road and tried to give him aid but he was aggressive towards them.
“He picked up a defibrillator, tried to throw it at them and then ran off across the car park.”
Police went to speak with Ellis, who was drinking from a can of lager, but he continued to act aggressively and made a punching motion towards them.
Mr Bozman said: “They took hold him but there was a struggle and to bring him under control one of the officers had to discharge his Pava spray.
“Eventually they got Mr Ellis to the ground where he was handcuffed.”
Magistrates heard that this put Ellis in breach of a two-year conditional discharge given to him following an incident in Great Northern Street On April 7.
Police were alerted as Ellis was acting strangely, standing in the road disrupting traffic and foaming at the mouth.
Mr Bozman said: “He called them devils and started to enter their personal space, telling them that he wanted to be arrested to that he could get a lift home.
“At the police station he spat in the face of a special constable and had to be restrained using leg restraints and a spit hood.
“He was unco-operative, tensed his limbs and said that the officers were the work of Satan.”
For safety reasons his clothing had to be removed and he urinated on his new clothes before defecating on the cell door, resulting in deep cleaning being required.
Andy Day, mitigating, explained that Ellis has suffered four bereavements of close friends, including one who he found dead in bed.
He said: “He has failed to cope with these circumstances and unfortunately has reverted to alcohol as an unsuccessful coping mechanism.
“He’s very sorry for his behaviour and welcomes any help offered to him.”
Magistrates gave Ellis, of Princess Gardens in Dewsbury, a community order with 15 days of rehabilitation activities.
He must pay £85 costs and £85 victim surcharge.