New York City Mayor Bill de Blasio attended Friday evening prayers at a Queens mosque, promising “to protect this community” against a backlash in the aftermath of the San Bernardino, California, slayings by husband-and-wife killers.

Speaking at Jamaica Muslim Center before kneeling worshippers in kufi prayer caps, de Blasio said “this is a religion of peace” that the NYPD would keep safe from reprisals.

“The few in any community who have chosen a negative path and a violent path do not define the rest of us,” de Blasio said in remarks that elicited applause.

He added: “We reject the notion that we will be torn apart.”

De Blasio made his remarks before the prayer service began.

“We reject hatred in all its forms, and we need to be clear that the cycle of hatred is such a dangerous one. Incidents occur and they are tragic and they are awful, and some people are tempted to lash out, and we know that members of the Muslim community are deeply concerned,” de Blasio said at the front of the men’s prayer room.

Hundreds of Muslims, mostly from Queens, packed the room and overflow spaces to listen to the mayor.

advertisement | advertise on newsday

“Everybody’s anxious, and they’re scared what happened,” said Mahmudur Rahman, chairman of the center’s board of trustees.

De Blasio, flanked by NYPD officers, elected officials and other aides, promised “to deepen the relationship” with the city’s Muslims.

“Whatever he said is from the heart, and it was really, really helpful for the Muslin community,” said Mahmood Alauedin, 50, of Queens Village, who owns a gas station on nearby Hillside Avenue.

Alauedin said the attackers in California “have to be” mentally ill to have killed so wantonly.

“There are a lot of crazy people,” he said. “Normal people cannot do that.”

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

The attack in San Bernardino this week, which killed 14 and injured 21 others, is being investigated as an act of terrorism, the FBI said.

Earlier Friday, de Blasio announced that three Syrian refugee families had arrived in the city to live, while Texas is in court to challenge the Obama administration’s right to place them in that state.

“While the state of Texas pursues a baseless attempt to resist their resettlement in the state,” de Blasio’s office said in a statement, “we welcome them with open arms to the city of immigrants.”