Hundreds of New Yorkers and tourists on Sunday packed the pews of St. Patrick’s Cathedral where Cardinal Timothy Dolan reminded them that God “is crying” when acts of terrorism and violence are committed in his name.

Dedicating his annual Sunday Veterans Mass homily to the eight people killed and at least the dozen injured in Tuesday’s terrorist attack by a suspected Islamic State group supporter, who mowed down bicyclists and pedestrians with a pickup truck on a lower Manhattan bike path, Dolan appealed to the city to remain resilient and remember that terrorism is not an act of God.

“Shouting the name of God, like it was done last Tuesday, after a vicious attack on innocent people — by a crazed fanatic shouting the name of God — don’t you think that God is saying this is not the way I made you or intended you to be.”

The cardinal also referred “to the carnage of war” and “the bloodshed of Las Vegas” as other examples of violence that are not acts of God, and that people should not lose hope.

Dolan then had asked parishioners and visitors “pray for families who are grieving, and for those who are recovering and for a city that still grieves.”

After the Mass, Dolan elaborated on his sentiments with reporters. “When you hear the name of God in that moment of sadness we are tempted to lose hope, which happened on Tuesday. The place to say God is here [in church].”

Barbara DiFiore, 57, of the Bronx, said Dolan’s remarks “gave hope for the city that reminds us that we are resilient.”

Her husband, Julius Di Fiore, 58, said, “I thought it was important that he address what happened Tuesday, especially when something is done in the name of God. . . . God is life, not of death.”

Meta Holcomb, 71, of Pasadena, California, said: “I thought it was beautiful. This is a beautiful city and it makes me extremely sad to see what happened here.”

Suspected terrorist Sayfullo Saipov, 29, whom authorities are calling a lone-wolf terrorist, was shot by an NYPD officer after allegedly driving down the bike path next to the Hudson River on Halloween and running over people with a rented truck. Saipov, of Paterson, New Jersey, survived and is being held on federal terrorism charges.