Officers from Nassau County police and the NYPD will work in pairs after five police officers in Dallas were shot and killed and seven others wounded Thursday night in a sniper ambush.

Each department, as well as Suffolk County police, said Friday it is monitoring the developments in Texas and is prepared to react should incidents arise.

“In an abundance of caution ... for the time being all of our officers will be doubled up,” NYPD Commissioner William Bratton said.

The NYPD is working with authorities in Dallas “to gather intelligence” to determine any linkage to threats on New York City, Bratton said.

Police officials said there have been 17 threats against police officers and all of those threats are being investigated — though none of those threats are considered credible.

“Each one of these is not treated callously. They are investigated very thoroughly,” Bratton said.

NYPD spokesman Stephen Davis said his department will be posting an officer outside every precinct; earlier, the department said it has two counterterrorism units prepared to respond to any threats.

City officers previously were ordered to patrol in pairs in December 2014 when NYPD Det. Wenjian Liu and Det. Rafael Ramos were killed in Brooklyn by a gunman who fired shots into their cruiser.

“This was an evil and unacceptable attack,” de Blasio said of the deadly ambush in Dallas. “It was an attempt to undermine our values and any attempt at peaceful democratic protest. This was an effort to undermine everything our democracy is about.”

“An attack on our police it is an attack on all of us. It is an attack on our larger society and everything we hold dear.”

De Blasio urged New Yorkers to console and thank a police officer today.

The mayor promised “a very substantial police presence at all protests.”

There will be “plenty of backup and support” at anti-police-brutality protests, he said.

De Blasio urged protesters to “really recognize the pain that our police are going through” and “be respectful” and “show some decency and respect.”

James O’Neill, NYPD’s chief of department, said arrests will be made if protesters “engage in significant acts that go outside . . . constitutional protections.”

In Nassau, police said in a news release that officers would work in pairs in vehicles as the department continues to assess the situation in Dallas.

Police in Nassau also will intensify patrols in areas of public gatherings and near critical infrastructure, officials said.

Suffolk County police said in a news release that enhanced measures will be implemented to increase officer safety but did not address specifics.

In addition, Suffolk police will reach out to “ensure the safety of all of our residents and to strengthen the partnership with the communities throughout” the county.

The leaders of the NYPD and Nassau police unions also said they mourned the loss of the Dallas officers and offered condolences and sympathies to the families.

“New York City’s police officers know how it feels to lose fellow officers in a senseless, coldblooded assassination,” Patrick J. Lynch, president of the Patrolmen’s Benevolent Association of New York said. “As we go forward, we need to take an honest, hard look at everything that wrongfully inflames emotions against police officers if we are going to be able to bring police officers and the community together.”

Lynch said NYPD officers “stand with the men and women” of the Dallas departments, their families and mourn the loss.

James Carver, president of the Nassau Police Benevolent Association, called the shootings in Dallas “senseless” and mourned the loss.

“These shootings are yet another reminder of the dangers police officers face in their daily working lives,” Carver said. “An officer putting on a uniform in the morning can never say with complete certainty that he or she will see loved ones in the evening.

“It takes a special kind of dedication to do this kind of work ... ”

Lt. Thomas Antonetti, an NYPD spokesman, said Friday the department offers its prayers and condolences to the Dallas police departments.

Antonetti said the critical response command and the strategic response group are prepared to “provide an overlay” of protection and support in New York City.

The critical response unit most recently was deployed as extra security during the Fourth of July fireworks event, and in response to terrorist attacks in Baghdad, Bangladesh and Istanbul, according to published reports.

The strategic response group, among other special units, was deployed after the mass shootings in Orlando, Florida, on June 12, news reports said.

With Anthony M. Destefano