Homeland Security Secretary John Kelly told Congress Tuesday that some federal grants given to “sanctuary cities,” including New York, could be suspended on a case-by-case basis.

Kelly also conceded the rollout of the immigration and travel ban was botched, the first such admission by an administration official.

“In retrospect, I should have — this is all on me, by the way — I should have delayed it just a bit so that I could talk to members of Congress, particularly to the leadership of committees like this, to prepare them for what was coming,” Kelly told the House Committee on Homeland Security.

While making amends with lawmakers, Kelly vigorously defended President Trump’s executive order temporarily blocking non-US citizens traveling from seven predominantly Muslim countries and all refugees, and said cities that don’t cooperate with the feds would be punished “case by case.”

“If we are specifically giving grants for cooperation on the removal of illegal aliens and the department or city is no longer doing that, it seems irresponsible to me to continue giving them the money. But it will be case by case,” Kelly said.

Mayor de Blasio has said New York would not change its policy regarding offering undocumented immigrants sanctuary despite Trump’s threat to withhold some funding from sanctuary cities.

De Blasio said last month about $150 million was at stake, most of it for antiterror policing.

Trump’s executive order on Jan. 25 protected police from funding cuts, so it’s unclear to which grants Kelly was referring.

Kelly also toned down some of Trump’s recent promises on curbing illegal immigration, answering questions about the president’s travel ban, the Mexican border wall and plan to add thousands of new border patrol agents.

Kelly said he did not expect to meet Trump’s hiring goals of 5,000 additional US Customs and Border Protection agents and 10,000 Immigration and Customs Enforcement agents within two years.

And he admitted that the border wall may include fencing and may not cover the whole border, and that he expected construction along parts of the border to be “well under way” within two years.

But Kelly never wavered in defending Trump’s travel ban, saying it made “an awful lot of sense.”

Democratic lawmakers who have argued that the travel ban is inhumane, counterproductive and essentially a Muslim ban assailed Kelly over the issue.

But Kelly denied that allegation and referred to the order as a “pause” that would give the United States time to fully evaluate how would-be visitors and refugees are being vetted before being allowed into the country.

In a tweet this week, Trump said, “Many very bad and dangerous people may be pouring into our country.”

Pressed by Rep. Bennie Thompson (D-Miss.) to address the claim, Kelly said the government won’t know for sure if someone with evil intentions entered the US “until the boom,” referring to a possible attack.