A man chased paramedics and police officers down a street with knives in his hands before being sprayed in the face with CS spray, Dundee Sheriff Court heard.
Stewart John Thomas Crawford, 26, a prisoner at Edinburgh, brandished two knives at Ross Wilson and Jamie Brannan, both paramedics who had been called to assist him, causing Mr Wilson to fall and bruise his knee and injure his wrist.
A police officer hauled him to his feet before he could be attacked.
Crawford also admitted assaulting PCs Craig Donaldson and Keith Leinster, challenging them to fight, chasing them with knives, spitting at them and kicking PC Donaldson on the body.
He also admitted possessing knives at 1 Parliament Square, Cupar, on October 27, all while on bail.
Depute fiscal Donna Brown told the court the accused had been drinking and had an argument with a friend, which ended with him being struck on the head with a bottle.
Paramedics and police arrived and the accused emerged from the close with blood on his face and carrying two knives, one in each hand.
He was repeatedly shouting threats, saying: “Come on then” and “I’m going to kill you.”
Ms Brown said he then ran at them and Mr Wilson fell to the ground.
“PC Leinster lifted him up and with the accused in a violent rage, PC Donaldson sprayed him in the face with CS spray.”
After being restrained he kicked PC Donaldson and spat repeatedly at the officers, the fiscal said.
Solicitor David Bell said Crawford, who had no previous convictions involving violence, did not remember anything and was apologetic.
He said: “They were there to help him and he was quite shocked when the story was read out to him.
“It was out of character.
Sheriff Elizabeth Munro told Crawford: “If you had a record with more violence I would have considered remitting you to the High Court for sentence.”
She jailed Crawford for three years.