It wasn't immediately clear if the attempted escape by 36-year-old Khojai Shujai was a suicide attempt.
But Shujai's attorney, James Giller, said his client has attempted to kill himself before.
Alameda County sheriff's deputies were able to subdue Shujai and take him back into custody.
The busy morning calendar of Judge Morris Jacobson continued while janitors cleaned up numerous shards of broken glass.
The incident was the talk of the courthouse, with District Attorney Tom Orloff and other attorneys chatting about it.
Giller didn't witness the incident because he was in a courtroom across the hall waiting for a sentencing in an unrelated murder case.
Shujai, an Afghan from Union City, is charged with murder and attempted murder for allegedly shooting to death 34-year-old Rahim Ansari at a travel agency at 3477 Fremont Blvd. in Union City in a district known as "Little Kabul" and wounding another man in January 2002.
Giller said that after Shujai was arrested he spent three years at a mental hospital in Napa.
But he said a jury recently found Shujai mentally competent to stand trial.
However, Giller said two out of three psychiatrists who examined Shujai recently found that he is mentally incompetent to stand trial.
Giller said Shujai was in court today for a routine pretrial hearing.
He said he hopes to have another competency hearing for Shujai soon.