The accused, identified as Mubarak Momin Khan, was produced in the court around 12.15 noon, when the incident took place.
He was arrested last year along with his four associates in suburban Powai here in a murder case.
"He was brought to court from Arthur Road Jail here for extension of his judicial custody. The accused suddenly threw his footwear, though luckily it did not hit the judge," the officer said.
A case has been registered at Colaba police station in this regard under IPC sections 504 (intentional insult), 353 (assault on public servant) and others.
This is the second such incident in the month, in which an undertrial hurled a footwear at a sessions judge, police said.