Long Island and New York City police went on high alert Friday in the wake of the deadly sniper attack in Dallas, placing two officers in most marked cars and increasing monitoring of social media for potential threats against local law enforcement, officials said.

Nassau County police, the NYPD and Suffolk County’s highway patrol put the two-officer requirement into immediate effect, as did most major police departments nationwide.

The change in tactics is intended to protect officers against ambushes like the one in Texas, authorities said.

“The world has changed,” said Nassau’s acting Police Commissioner Thomas Krumpter, who announced Friday that his officers would also have access to more rifles and bulletproof vests in light of the killings. “These are uncertain times for policing. These are uncertain times for the public.”

The Dallas attacks left five officers dead. Seven other officers and two civilians were also wounded before police used a robot to deliver a remote-controlled bomb and kill the shooter, authorities said.

advertisement | advertise on newsday

Before his death, the gunman told negotiators he was upset about recent fatal police shootings of blacks in a suburb of St. Paul, Minnesota, and Baton Rouge, Louisiana, and that he wanted to “kill white people” — especially white officers, the Dallas police chief said.

Should a similar ambush be attempted in New York City, Nassau or Suffolk, police said they have the necessary robots and explosives to carry out a similar operation.

“Yes, we have that capability,” Krumpter said.

Law enforcement agencies across the region, meanwhile, were stepping up efforts to gather information on potential threats against police.

Suffolk police officials said they were receiving briefings containing FBI intelligence on the Dallas attacks. The department increased its own intelligence-gathering on social media as well, combing sites such as Twitter and Facebook.

Additional SWAT teams, bomb squad teams and explosives-detection dogs are also ready for action, said Suffolk Police Chief of Department Stuart Cameron.

“I think it’s reassuring to the public,” Cameron said. “An attack on law enforcement is an attack on the very fabric of society.”

Nassau and Suffolk police said they are increasing outreach efforts in minority communities, members of which have been disproportionately affected by police-involved shootings, data show.

advertisement | advertise on newsday

The NYPD was working with authorities in Dallas “to gather intelligence” to determine any linkage to threats in the five boroughs, Police Commissioner William Bratton said.

Department officials said Friday afternoon that there have been 17 threats against city police officers since Thursday night. All are being investigated, they said, though none so far are considered credible.

NYPD Chief of Intelligence Thomas Galati said one example was a report to authorities about a man who said he would travel to New York “and if he ran into police, he would, in fact, try and kill” them. The incident turned out to be a domestic dispute, Galati said.

NYPD spokesman Stephen Davis said the department began posting an officer outside every precinct on Friday. Auxiliary cops, who are unarmed save for batons, will not be used in the field for the next few days, police said.

City officers were previously ordered to patrol in pairs in December 2014, when NYPD officers Wenjian Liu and Rafael Ramos were killed in Brooklyn by a gunman who fired shots into their cruiser. The killer in that case, Ismaaiyl Brinsley, had expressed his anger at police and government on social media. The mentally ill man took his own life on a subway platform after the ambush.

advertisement | advertise on newsday

The Dallas killings were “eerily similar” to the 2014 assassinations, Bratton said.

“This is a continuing crisis in this country that needs to be addressed,” the commissioner said.

Bratton added: “In 45 years in the business, I have never seen anything quite like it in terms of a directed attack against police officers . . . because they were wearing a blue uniform. It is something we cannot tolerate. We cannot tolerate racial injustice, we cannot tolerate injustice directed against our police forces.”

With Maria Alvarez, Anthony M. DeStefano and Tania Lopez