A standoff between law enforcement authorities and a gunman, who for nearly two hours Thursday opened fire on officers from a second-floor perch in a Frankford rowhouse, ended abruptly when the man was fatally shot.

The firefight broke out just before 1 p.m. as state parole officers and U.S. Marshals arrived at the house in the 4600 block of Hawthorne Street, near Orthodox Street, to serve an arrest warrant, Philadelphia Police Deputy Commissioner Robin Wimberly said.

The man they were there to arrest retreated inside and started shooting. SWAT trucks and dozens of Philadelphia police officers swarmed the block in response.

Investigators had not identified the attacker as of Thursday evening. No other injuries were reported.

But as bullets rained down from above, the chaotic scene sent officers ducking for cover, five neighboring schools into “lock-in” status, and residents cowering in their homes.

As the shooting continued while classes were due to let out at Allen M. Stearne Elementary School on nearby Unity Street, a crowd of worried parents gathered.

Lakeisha Cleveland, 29, said she heard what sounded like more than 10 gunshots while inside her home on Mulberry Street, a half-block away. She ran toward Stearne, where her 7- and 9-year-old children are enrolled. Before she could get there, police told her to run.

“My kids are stuck inside … without their parents,” she said. “I just want my babies back.”

Others reported seeing SWAT officers firing beanbags at the rowhouse’s windows in an attempt to reach the shooter.

“SWAT responded to the job [and] tried to make contact with the male,” Wimberly said. “[He] came to the window, began firing upon the SWAT officers. They returned fire and he was struck.”

Thursday’s shooting incident took place nearly six months after another gunman barricaded himself inside a rowhouse less than five miles away and shot at police for nearly seven hours.

Maurice Hill, 36, injured six officers from his perch on the second floor of a home on the 1500 block of North 15th Street in Tioga before he surrendered. He is awaiting trial on several counts of attempted murder.

Staff writers Maddie Hanna, Anna Orso, Claudia Vargas, and Chris Palmer contributed to this article.