Judge Patricia Lynch QC was sentencing John Hennigan at Chelmsford Crown Court for his ninth breach of an anti-social behaviour order in 11 years when the exchange took place.
The 50-year-old was in the dock when he told Judge Lynch she was a “bit of a c***”, to which she responded: “You are a bit of a c*** yourself. Being offensive to me does not help.”
Shouting back, Hennigan said: “Go f*** yourself,” to which the QC replied: “You too.”
Judge Lynch jailed him for 18 months for insulting and making racist slurs against a black Caribbean mother in Harlow, Essex.
After news of her four-letter retort circulated, scores of people took to social media to praise her reaction and choice of words - with many branding her a “hero” and an “idol”.
Stan Keaton tweeted: “Judge Patricia Lynch QC has a cracking reply to a racist thug in her courtroom.”
David Duncan added: “What a legend judge Patricia Lynch is,” while Gemma Tomlinson wrote: “I would like to buy judge Patricia Lynch a drink.”
Greg Stone tweeted: “Judge Patricia Lynch, a nation salutes you.”
Luke Farley said: “Hats off to Judge Patricia Lynch. I think it was a reasonable response given the vile racist in front of her.”
Marc Thomas posted: “It is a bit hard to give children role models nowadays but Judge Patricia Lynch QC is definitely one.”