Timothy Mulqueen, of Middletown, opened fire with a 12-gauge shotgun in the lobby of his hometown courthouse at about 9 a.m. Officers returned fired as people in the building dove under desks and scrambled for the rear door, authorities said.
"He had more rounds for the shotgun and had he made it past the officers, who knows what mayhem might have ensued," said David Bookstaver, spokesman for the state office in charge of New York's local court system. "It appears at this point that the officers may have saved countless lives."
The 43-year-old Mulqueen died at a hospital. One of the officers suffered a graze wound to the arm, and two others were treated for shock.
Police and witnesses said Mulqueen rode a motorcycle to the city's downtown, went to City Hall first and then ran to the courthouse in Middletown, a city of about 25,000 in the Hudson Valley, about 60 miles north of New York City.
Orange County District Frank Phillips said the investigation is continuing. It wasn't immediately known how many shots were fired.
Mulqueen's motive wasn't clear, but court records show he had been arrested on menacing, trespass and harassment charges after an encounter with the 23-year-old daughter of Mayor Joseph DeStefano at their home in August.
Nicole DeStefano told police she heard a "violent knocking" on her front door on the evening of Aug. 6 and answered it to find Mulqueen asking for her father.
"This person then got agitated after I told him my father was not home. This person started to make violent hand gestures and he began to yell at me," DeStefano said, according to court records. "The way this person was behaving made me fear for my safety."
She said he was dressed in a camouflage hat and black shirt and was carrying a black satchel.
Mulqueen was arrested after her family filed a complaint with police.
"Yeah, I knew it was Joe-Joe's house. I needed to talk to him about something," he told police. "I don't want to talk with you."
The mayor said Wednesday evening that Mulqueen was armed with a machete, razors and homemade weapons made with nails and sticks when he showed up at his house.
"We had a long history," DeStefano said. "He was arrested in 2000 and spent a few days in jail after we had a crackdown on housing code violations. He ended up losing his properties."
DeStefano said Mulqueen owned quite a few properties and some had major code violations. "We took him to court to force him to correct them," DeStefano said. "He was arrested after he ignored a court order to make repairs."
DeStefano said Mulqueen had been living on disability and had "mental health issues."
The mayor said he didn't know what led to Mulqueen's courthouse confrontation on Wednesday.
On Feb. 1, Mulqueen was convicted on the harassment charge and fined $129. His lawyer didn't immediately return a call Wednesday.