A gunman carrying a rambling note titled “Doomed People” fired 18 shots at an unsuspecting Philadelphia police sergeant Friday night, then tore through the city’s west side with his gun, killing a woman and injuring several others.

The suspect, Nicholas Glenn, who police believe was 25, was killed a half hour after the initial ambush. He was cornered in an alley by three officers who chased him through crowded Philadelphia streets while he fired indiscriminately at random passersby.

In all, six people were shot by the gunman — including two injured officers and the 25-year-old woman who was killed, according to Philadelphia Police Commissioner Richard Ross. All of the injured were expected to survive, Ross said in an afternoon press conference.

“This was a horrific night,” Ross said. “…You can’t get your brain around it. He was hellbent on hurting a lot of people.”

Investigators found a “rambling” letter on the gunman’s corpse that, while somewhat incoherent, expressed anger toward the man’s probation officer and police in general.

Ross said the shooter didn’t appear to be motivated by terrorism or religious beliefs, like a man who ambushed a Philadelphia officer multiple times in January. That shooter later pledged loyalty to ISIS.

The attack was one of several across the nation over the weekend. On Saturday, a man armed with a knife stabbed eight people inside a Minnesota mall. Police haven’t given a motive in the attack, but said the man made reference to Allah and asked at least one person whether they were Muslim.

And 29 people were injured in a Saturday night attack in the Chelsea neighborhood of Manhattan during an explosion that authorities believe was an intentional act.

Mayor Bill De Blasio said there was no immediate terror connection, but a law enforcement official told The Washington Post that a second explosive device appeared to be similar to a pressure cooker with wiring on it. Similar devices were used in the two bombs detonated at the Boston Marathon in 2013.

Even though there was no terror link in the Philadelphia shooting,  an official police Twitter account said early Saturday that it was the work of “an individual driven by hatred.”

The violence started at 11:18 p.m. Sgt. Sylvia Young, 46, working on a violent crime task force in West Philadelphia, was sitting in a marked cruiser at 52nd and Sansom streets when the gunman approached without warning, Ross said.

The gunman fired 18 times, Ross said, striking Young several times in the arm. Two bullets lodged in Young’s bullet resistant vest. Another two struck her service pistol, disabling it.

“I don’t know if she would have been able to return fire if she wanted to,” Ross said.

All she could do was lean into the passenger seat to try to avoid the fusillade of gunfire, Ross said.

Seconds later, she could be heard on the police radio: “I’m at the McDonald’s on 51st St.,” she screamed. “Help me, please!”

After shooting Young, the attacker ran away, headed east on Sansom Street, with officers chasing him, Philly.com reported.

“We’ve got shots fired at us!” one officer can be heard yelling into his police radio during the chase.

As the shooter ran, he fired shots into a bar, wounding a security guard, according to Philly.com. Later, he grabbed a woman and used her as a human shield. Then he shot her in the leg and kept running.

At 49th and Sansom, the gunman fired at two people sitting in a car, striking a man and a woman in the chest, Ross said. The woman, who was hit several times in the torso, later died of her injuries, while the man was listed in critical condition, but is expected to survive.

The police radio traffic punctuated the carnage:

“Be advised, we need a medic,” one officer says. “We have a male shot in the leg, bleeding profusely.”

Later, an officer said of the gunfire: “It’s coming from everywhere down here.”

Around 11:45 p.m., in an alley at 48th and Sansom, a University of Pennsylvania police officer and two Philadelphia police officers cornered the man, shooting and killing him during a brief gun battle, Ross told reporters. The university officer was shot in the buttocks and the leg.

The Associated Press identified that injured officer as Ed Miller, who formerly worked for the Philadelphia Police Department.

Philadelphia Mayor Jim Kenney told ABC affiliate WPVI that the officers were awake and conscious when he visited them early Saturday.

“I had the opportunity to be with both police officers this evening, and their families,” Kenney told WPVI. “One officer was cracking jokes with his kids and wife. The other officer was talking with her family. So we are happy, very blessed, that that’s the way it turned out. I think we have to keep them in our prayers.

“The civilians, there are some seriously hurt, and still in various degrees of being treated. And I think all in all it was really a terrible, scary night. But our officers turned out okay, and hopefully the civilians will turn out okay.”

The shootings in Philadelphia followed similar, ambush-style shootings in July that left five police officers dead in Dallas and three dead in Baton Rouge.

Chief Ross said he wasn’t sure if Glenn was motivated by anti-police sentiment or if he was simply mentally unbalanced.

“I’m not a physician and so couldn’t speak to (whether the suspect was mentally disturbed),” Ross said.

“But you would have no difficulty proving that to me. There are some issues that were going on there — to go down and so violently fire upon so many different people who basically have no issue with you and didn’t have any encounters with previously.”

This post has been updated.

Read more: 

After shootings, police fear being ‘a public target’ — even at lunch

One-third of officers killed responding to calls were alone, new study of police deaths finds