Buildings shook and glass shattered as a bomb spewed shrapnel in the Chelsea section of Manhattan on Saturday night. First responders and strangers rushed in to help dozens of injured bystanders, and soon, an unexploded device was found a few blocks north.

Across the country at a Minnesota mall the same night, a man stabbed nine people before he was shot to death. In New Jersey earlier in the day, a pipe bomb exploded during a charity running race, but resulted in no injuries.

The incidents underscored a sense of vulnerability that New Yorkers are familiar with: Such violence could happen anywhere at any time.

The city coped quickly. Twenty-nine people who suffered injuries on 23rd Street were treated on the scene or at hospitals. All were soon released.

Setting a tone of measured preparedness, Mayor Bill de Blasio and new Police Commissioner James O’Neill urged the public to cooperate with law enforcement. O’Neill noted the department’s work in foiling 20 plots against New York City since 9/11.

Whether or not all 20 of those plots were true threats to the city, the NYPD is well-suited to thwart organizations plotting large-scale attacks. But there seems to be little law enforcement can do to stop smaller attacks and less organized actors, no matter what grievance inspires their violence. That was true in the bombing at the Boston Marathon in 2013, and when a car bomb failed to detonate in Times Square in May 2010.

advertisement | advertise on newsday

Saturday’s bombing could have been far worse. Defending against similar attacks, be they terrorism foreign or domestic, is very difficult. New Yorkers must help police with tips and cooperation.

New York City is the world’s prime terrorist target, so even the suburbs are not safe, as we saw with the Saturday morning bombing in Seaside Park, New Jersey. Regional and interagency cooperation are critical to keeping us safe.

Once again, officials asked New Yorkers to be vigilant. They will be, as they have been before. That cooperation is essential and must continue. — The editorial board