Attorney General Jeff Sessions came to New York City Thursday, just two days after a terror attack, and defended the immigration policies of President Trump.

“The president was right to issue his executive order, the travel ban, so called,” the attorney general said.

He said the host countries targeted by the president did not properly screen people coming to America.

They “are countries that have failed to properly effect, carry out, their business,” Sessions said.

He said it was important for Congress to reauthorize a law — Section 702 of the Foreign Intelligence Surveillance Act — that allows U.S. agencies to conduct surveillance overseas.

“We cannot afford to let this law expire” — which it does in two months, he said.

Sessions’ speech came in the wake of the terror attack on Tuesday when, officials said, an immigrant from Uzbekistan, Sayfullo Saipov, 29, killed eight people and injured at least a dozen by running them over with a rented truck on a West Side bicycle path.

Saipov entered the United States legally in 2010 under a program called the diversity visa lottery, and Sessions said Congress should abolish that in favor of a merit-based system.

Sessions spoke at the office of the U.S. attorney for the Southern District of New York, just steps away from both the courthouse where Saipov was arraigned Wednesday and the federal detention facility where he is being held.

With William Murphy