Judge Joseph Bruzzese was shot several times, but returned fire in a gunfight outside his chambers.
A US judge in Ohio has fatally shot a gunman who critically wounded him in an ambush-style attack outside court.
Judge Joseph Bruzzese Jr was shot several times just after 08:00 local time (12:00 GMT) in Steubenville on Monday morning.
Sheriff Fred Abdalla told reporters the attacker and the judge exchanged about five shots each.
A court officer also fired several shots at the suspect.
The Jefferson County prosecutor identified the attacker as Nathaniel Richmond, but said they had not yet identified a motive.
Mr Richmond is the father of Ma’Lik Richmond, a high school football player whose rape conviction made national headlines in the 2012.
Prosecutor Jane Hanlin said there is no connection between Judge Bruzzese and that rape case.
Judge Bruzzese, who has been on the bench at the Jefferson County courthouse since 1998, was airlifted to hospital in Pittsburgh to undergo emergency surgery.
The Steubenville city manager says that the judge is out of surgery and “doing fine”.
Sheriff Abdalla said he had advised the 65-year-old judge several years ago to carry a firearm during his commute.
“This individual laid in wait, for our judge,” the sheriff told reporters hours after the shootout.
“It just hurts. First thing on a Monday morning.
“You have a judge shot in front of his courthouse, and that affected me. This was ambush and attempted murder on our judge.”
Police have also detained the driver who brought the attacker to the courthouse, but say they believe he did not know what his passenger was plotting.
The sheriff added that both men had served time in prison.
“He’s shooting and shooting,” Sherriff Abdalla said at a news conference. “He’s right up to the judge.
“And that’s when he fires another round and he shoved the judge over and then he takes off running towards his vehicle.”
The courthouse has been closed for the rest of the day and for Tuesday as detectives process the crime scene.
The state governor has been updated on the situation and the Ohio Bureau of Criminal Investigation is leading the investigation.