A young man slashed a garda across the head with a kitchen knife when the officer went to investigate a reported stabbing on a Dublin street, it has been alleged.
Lee Quinn (24) is accused of attacking the garda as he tried to speak to a man who had been found with a wound to his side.
A court heard the garda, who was wearing a stab vest, was cut from his hairline to the crown of his head, but was "extremely lucky" to avoid more serious injuries.
Judge Paula Murphy refused Mr Quinn bail and remanded him in custody.
The initial stabbing incident is still under investigation.
Mr Quinn, of Keeper Road, Drimnagh, is charged with assaulting and obstructing a garda and possession of a knife.
The incident is alleged to have happened at St Vincent's Street West in Inchicore on Monday.
Objecting to bail, Detective Sergeant Brian Hoey told Dublin District Court that gardai were called to a reported stabbing at Tyrone Place.
On arrival, they found a man nearby with a stab wound to the left side of his torso and a garda attempted to engage with him.
The man began acting in an aggressive and threatening manner, refused to engage with the garda and walked away before returning and continuing to act aggressively.
Mr Quinn then arrived, carrying a large kitchen knife with an eight-inch blade, Det Sgt Hoey added.
It was alleged that Mr Quinn approached the garda from behind and attempted to stab him on the right side of the abdomen.
He also allegedly slashed at his head, striking him on the crown. The court heard that the garda sustained a large cut.
It was alleged he was att-acked by both men and all three fell to the ground.
Mr Quinn swung the knife in a downward motion and the garda held on to his arm, preventing this, Det Sgt Hoey said.
Dublin Fire Bridge ambulance personnel arrived and dragged the accused off the garda.
The alleged victim was treated at St James's Hospital for a cut to his head and grazes to his hand. He was also X-rayed for a suspected fracture to a finger, but it was not broken.
Det Sgt Hoey said the accused was arrested at the scene and a knife was recovered.
The alleged incident was witnessed by numerous members of the fire brigade and there was CCTV footage.
Det Sgt Hoey said the accused was highly-intoxicated when he was arrested and a doctor deemed him unfit for interview for eight hours.
He was co-operative with gardai, but made no admissions, the court heard.
The DPP had directed trial on indictment.
"The garda was extremely lucky to get away with the injuries he did get away with from the attack," Det Sgt Hoey said.
The officer had been wearing a uniform and stab vest.
Applying for bail, defence solicitor Ruth Walsh submitted a psychiatric report on the accused.
She said she had significant concerns about her client's mental health.
He could spend a long time on remand, and custody was "simply not an appropriate place for him".
Ms Walsh said "we are in a very strange and unusual situation due to Covid-19", and she could imagine the strain on prison psychiatric services.
It would be "absolutely detrimental" to the accused to be remanded in custody, she added.
Mr Quinn's mother was concerned about her son's mental state and had wanted to attend court and support him, but Ms Walsh had told her it would not be appropriate.
Judge Murphy took into acc-ount the accused's presumption of innocence.
However, he said the charges were serious, and she did not believe the objections could be met by way of bail conditions.
She directed that Mr Quinn receive appropriate medical treatment in custody and adjourned the case to today, when he was due to appear at Cloverhill District Court.
The judge also granted free legal aid.