By Justin Madden and Fiona Ortiz

(Reuters) - Two bailiffs were shot dead during a scuffle with a prisoner turned gunman inside a Michigan courthouse on Monday, that left two people wounded before police officers killed the shooter, a county sheriff said.

"At about 2:25 (p.m.), we had a disturbance on the third floor of the courthouse. A person has shot two bailiffs, they are both deceased," Berrien County Sheriff Paul Bailey said in a news conference.

Bailey said the shooter was a prisoner who took a gun from one of two bailiffs escorting him to a courtroom in the St. Joseph courthouse, and then began shooting as he tried to escape from custody. A sheriff's deputy and civilian were also injured, he said.

"Our hearts are torn apart. They were our friends," Bailey told reporters. "It's a sad day."

Bailey said the deputy and civilian who were shot were taken to the hospital and were expected to survive.

The suspect was shot and killed by police officers, he said.

Chris Gautz, public information officer for the Michigan Department of Corrections, tweeted that all Department of Corrections staff were safe and accounted for.

The shootings of the bailiffs and the deputy came four days after four Dallas police officers and one Dallas transit police officer were killed by a sniper who claimed to be motivated by police use of lethal force against African-Americans.

A witness, Gretta Volkenstein, told CNN that buildings and government agencies in the area were placed on lockdown as the incident unfolded.

It was not immediately known why the prisoner was being escorted to the courtroom. Bailey said that was part of the ongoing investigation.

"MSP (Michigan State Police) has secured the scene at the Berrien County courthouse and started its investigation into the shooting that occurred this afternoon," Governor Rick Snyder said on Twitter.

The courthouse would be closed on Tuesday, Bailey said, and he would not name any of the victims until they families were notified.

St. Joseph is a town in southwest Michigan, across Lake Michigan from Chicago.

(Reporting by Justin Madden and Fiona Ortiz in Chicago; additional reporting by Eric Beech in Washington, writing by Fiona Ortiz; editing by James Dalgleish, G Crosse)