Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

New York City's leaders and residents vowed that the city would not be intimidated by acts of violence, after a driver plowed a truck into cyclists and pedestrians on a Manhattan bike path Tuesday in what police were treating as a terrorist event.

"We know that this action was intended to break our spirit," Mayor Bill de Blasio said at a news conference. "But we also know New Yorkers are strong, New Yorkers are resilient and our spirit will never be moved by an act of violence, an act meant to intimidate us."

The driver drove a rented Home Depot truck onto a bike path near the West Side Highway, crashed into a school bus and exited shouting "Allahu Akbar," police and witnesses said. He had a paintball and a pellet gun, and he was shot by police and taken into custody, police said.

Eight people were killed and 11 others had serious but not life-threatening injuries, police said.

Jordan Dattoma, 13, and Ruby Klein, 13, eighth graders at nearby IS 289 Hudson River Middle School, were walking out of campus when they heard a shouted warning.

"Our friend goes: 'Go, go, go! There's a gun! There's a gun!,'" Jordan recalled. "Everyone starts running back upstairs."

They went up to the fifth floor of the school and were put on lockdown in a classroom. All of the children were crying, including Jordan and Ruby. They called their parents to say they were safe.

The attack occurred just hours before the city's highly anticipated Halloween parade.

"Our friend goes: 'Go, go, go! There's a gun! There's a gun!"

"People have no emotions. That's the best way I can describe it," Kevin Morocha, 19, a student at the Borough of Manhattan Community College, said at Greenwich and Chambers streets about 45 minutes after the rampage. "People are just stunned and shocked."

Morocha, who was wearing fake blood and face paint for Halloween, said he still planned to attend the Halloween parade.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Chris Valez, 24, also a student at the college, said: "It's crazy. I mean, it's Halloween night."

The streets of New York City were lined with revelers for the parade. Jack-o’lanterns and skeletons operated by puppeteers towered over the crowds, and marchers hoisted a segmented snake as the parade kicked off.

"We've all got to come out here and enjoy ourselves — that’s the bottom line," one participant dressed as a Rebel pilot from the "Star Wars" movies told NBC News at the parade. "We've got to live, love and survive."

President Donald Trump said on Twitter: "In NYC, looks like another attack by a very sick and deranged person. Law enforcement is following this closely. NOT IN THE U.S.A.!"

His wife, Melania, tweeted: "My heart breaks for #NYC today. Thoughts & prayers as we monitor the situation."

My thoughts, condolences and prayers to the victims and families of the New York City terrorist attack. God and your country are with you! — Donald J. Trump (@realDonaldTrump) October 31, 2017

New York Police Commissioner James O'Neill called the attack a tragedy, saying, "The dead and injured were just going about their days, heading home from work or from school or enjoying the afternoon sun on bicycles."

Cardinal Timothy Dolan, the archbishop of New York, said, "Today our city and our nation are stunned and horrified by another act of senseless violence."

"While details continue to emerge, one thing is clear: Once again, no matter our religion, racial or ethnic background, or political beliefs, we must put our differences aside and come together in faith and love to support those who are injured, pray for those who have died as well as their families and loved ones, and work towards greater respect and understanding among all people so that heinous and evil acts like this become a thing of the past," Dolan said in a statement.

Halloween revelers attend the 44th Annual Village Halloween Parade on October 31, 2017 in New York City. Dia Dipasupil / Getty Images

Tuesday's attack happened near Chambers Street and the West Side Highway, which is north of the site of the Sept. 11, 2001, terrorist attack on the World Trade Center.

"We have been tested before as a city very near the site of today's tragedy, and New Yorkers do not give in in the face of these kinds of actions," de Blasio said. "We'll respond as we always do, and we will be undeterred."

Singer Josh Groban said he was at a nearby dog park when he heard eight to 10 gunshots. "Be safe with your kids out there," Groban said on Twitter.

Devastated for the victims and their families tonight & inspired by the spirit of this city. Sirens and trick or treaters everywhere. 💙🗽 — josh goblin 👹 (@joshgroban) October 31, 2017

New York Gov. Andrew Cuomo said that there would be more police in New York City but that there was no ongoing threat. He said that based on the current information, it appeared that the suspect acted alone and that there was no larger plot.

"The truth is, New York is an international symbol of freedom and democracy. That's what we are, and we are proud of it," Cuomo said. “That also makes us a target for those people who oppose those concepts.

"And we've lived with this before. We've felt the pain before we feel the pain today — but we go forward together, and we go forward stronger than ever," Cuomo said. "We're not going to let them win. And if we change our lives, we contort ourselves to them, then they win and we lose. We'll go about our business."

Zipporah Genyard, 21, a student at the Borough of Manhattan Community College who was wearing a "water goddess" costume, said she still planned to attend the Halloween parade and was heartened by officials' pledge that there would be increased security.

"I'll feel safe as long as the NYPD does their job," Genyard said.

Calvin Liang, 16, a student at Stuyvesant High School, near where the attack occurred, said he was locked down for three hours. He had been a lifeguard at the school pool, and from the pool area he and other students could see two bodies covered by tarps, he said.

Calvin said he didn't plan to attend the Halloween parade, but only because he's finishing college applications.

"I suppose terrorism is a fact of life," he said. "But we can't stop living our lives, because that's what they want."

Daniel Arkin reported from New York, and Phil Helsel from Los Angeles.