Barrymore, born Michael Parker, admitted the charge at Ealing magistrates court, west London. A second charge, of being drunk and disorderly, was withdrawn.

Barrymore appeared shaky as he entered the west London court dressed in a dark suit, white shirt and maroon tie.

The court was told police officers approached the car at 4.30am after noticing it was damaged.

They asked Barrymore who had been driving, he replied: “I am not answering you”, the court heard.

He continued: “Don’t you think I’ve had enough fucking shit from you lot over the years? I know the law.”

At the station, Narrymore tried to hide what looked like a white substance in his mouth, the prosecutor said.

“He refused to spit it out, was strip-searched and a rock of cocaine was found in his pocket,” she told the court. A test showed he had taken the class A drug.

Barrymore’s lawyer, Richard Gowthorpe, said the quantity of cocaine had been described as “a very small amount” and that the entertainer had apologised to the police for his behaviour.

While he now had a criminal conviction, his client had entered the court a man of good character, he said. “In many ways it’s a sad day for Mr Parker to be before the courts and he’s pleaded guilty to this offence,” he said.

“Certainly he will be punished to a degree by the conviction itself.”

The court heard that Barrymore had been seeing a drug worker since the night of the incident and was making “very good progress”

Drug worker Andrew De Cruze said: “Steps have been put in place to support Mr Parker in any way we can.

“He’s undergoing cognitive behavioural therapy. It’s something Mr Parker has found very helpful and is willing to engage further in that process.”

Barrymore was also addressing his alcohol use and had been attending Alcoholics Anonymous meetings, Mr De Cruze told the court.