The shootout rang on Monday afternoon local time when the inmate, who was being moved from a holding cell inside the Berrien County courthouse in St Joseph, Michigan, grabbed an officer's gun and shot at the four people, Berrien County Sheriff Paul Bailey said.
The inmate first shot a county sheriff's deputy, then fatally shot the two bailiffs. He then shot a civilian in the arm before he was taken down by a bailiff along with several other officers, he said.
Bailey said the suspect was shot dead by the law enforcers.
When the shooting broke out, the people inside the courthouse went for shelter, while "other brave officers were able to come to the rescue and take the shooter down," Bailey said.
"The courthouse is secured and the scene is rendered safe. No further victims are involved," Bailey said.
Bailey said the civilian and the sheriff's deputy suffered non-life threatening injuries.
The courthouse would remain closed on Tuesday.
The officials did not immediately release what the inmate was in custody for.
Michigan Governor Rick Snyder said the state police have launched a probe into the shooting.
"We all need to reach out and be supportive of law enforcement in our state and across the country," Snyder said in a tweet.
Last week five police officers were killed in Dallas by an Army veteran "protesting" the fatal police shootings of two black men in the US states of Louisiana and Minnesota.
UCLA shooter Mainak Sarkar an alumnus of IIT Kharagpur
Dallas shooter taunted, laughed, sang during stand-off with cops
50 killed in deadliest mass shooting in the US
Orlando shooting an 'act of terror', says President Obama
Dallas shooter backed black militant groups