One person was killed and at least four were injured when gunfire erupted outside a judge's office in Fayette County, Pa., on Wednesday, emergency officials said.

The shooting took place near the office of Magisterial District Judge Daniel Shimshock in Masontown, according to KDKA-TV, which reported that the incident was related to an ongoing domestic violence situation.

One of the injured was a police officer, Masontown Mayor Toni Petrus told the Pittsburgh Post-Gazette. Petrus said the officer's injuries were not life-threatening.

David Kaiser, an attorney who was at the judge’s office when the shooting occurred, said he heard an argument outside the office before the gunfire.

Xuan Sayles told KDKA he was in the parking in front of the magistrate's office when shots rang out and he watched a woman fleeing a man with a gun.

"I turned around and saw a guy with a gun and a lady was five to eight feet away from the shooter and his gun jammed up. He was trying to get it to shoot again and it wouldn’t shoot," Sayles said.

Others described the terror that descended on a packed courtroom when the shooting began in an outside area.

"The courtroom was very, very crowded. There were hundreds of people in there waiting to be serviced at 1 o'clock, and it was just a chaotic situation from the very beginning," Joyce Royster told WTAE-TV.

When the gunman started to move inside, people scrambled for cover in nearby offices, she said.

"Someone opened the door, and I had been on the floor, and we flew into the room and took cover in one of the offices. People were yelling, they were crying and they were very, very upset. Some people were injured, lost their shoes, lost their purses – they were just running for their lives."

Pennsylvania Police Troop B later tweeted that the scene was secure and no schools, businesses or offices were locked down.

Masontown is a rural borough that is part of the Pittsburgh metro area and has a population of about 3,400.

Earlier Wednesday, a gunman opened fire at a Wisconsin software company, wounding four people before being killed in a shootout with police.

More:Gunman dies after wounding 4 in shooting rampage at Wisconsin office building, authorities say

Contributing: The Associated Press