A lawyer who escaped a drug conviction after he allegedly lied to a retired judge who gave him a character reference has been charged with perverting the course of justice.

James Cowled, a judge's associate, was handed a 12-month good behaviour bond last year for drug possession after he was reportedly found snorting cocaine in the bathroom of a Sydney cocktail bar.

The 32-year-old avoided conviction with the help of a reference from his former mentor, retired Federal Circuit Court Judge Michael Lloyd-Jones.

But Judge Lloyd-Jones was told Cowled was facing a low-range drink-driving charge when he provided the reference, according to The Daily Telegraph.

James Cowled (right) has been charged with perverting the course of justice. He allegedly lied to retired Federal Circuit Court Judge Michael Lloyd-Jones (left) to get a character reference for his cocaine charge last year

Once he was made aware the young lawyer faced drug charges, he lodged a complaint to police, who have charged Cowled over the character reference, the paper reports.

At Cowled's court appearance in May last year, Magistrate Lisa Stapleton quizzed him on the character reference.

'You were found in possession of cocaine. If the person says this was out of character for you they don't know you very well so why shouldn't I convict you of this offence?' she questioned.

He replied by telling her he was a judge's associate, and the magistrate then asked to see the letter.

James Cowled, a judge's associate, was handed a 12-month good behaviour bond last year for drug possession after he was reportedly found snorting cocaine in the bathroom of a Sydney cocktail bar

The Sydney lawyer revealed he was embarrassed when he told his former mentor about the cocaine charge.

'I must say telling my former judge was one of the most difficult things I've done in my life,' he said.

Cowled faces up to 14 years in jail if convicted.