ST. PETERSBURG, Fla. —  A fugitive holed up in an attic and authorities fired more than 100 shots at each other Monday in a fight that killed two officers, wounded a deputy U.S. marshal and led to an hourslong standoff.

St. Petersburg police spokesman Michael Puetz said the suspect was found dead when officers went into the home Monday afternoon, about six hours after the shootout, the latest in a recent rash of shootings across the nation that have killed or wounded law enforcement officers.

Law enforcement had been at the home to arrest Hydra Lacy Jr., 39, around 7 a.m. on an aggravated battery charge, and investigators later identified him as the one who opened fire on the officers, Puetz said.

He said Lacy had a long record that includes convictions for armed robbery and sexual battery. He had been listed as a sex offender with the state since 1996 and failed to register in December with the Pinellas County Sheriff’s Department, which he was required to do four times a year. Deputies had been looking for him since then, and local officers on Friday had been told to be on the lookout for Lacy.

“He was somebody we wanted to get off the streets, ” Police Chief Chuck Harmon said. “Who expects to walk into a house and get gunfire from the attic?”

Monday’s shooting comes four days after two Miami-Dade County detectives were killed by a murder suspect they were trying to arrest. That suspect was killed by another detective.

On Sunday, a man opened fire inside a Detroit police precinct, wounding four officers including a commander before he was shot and killed by police. The officers’ injuries were not considered life-threatening, said Police Chief Ralph Godbee.

And on Monday, a Lincoln City, Ore., police officer was critically wounded when he was shot during a traffic stop.