WASHINGTON — The Trump administration, signaling its intent to toughen enforcement of immigration laws across the country, threatened on Monday to withhold or revoke law enforcement funding from states, cities and localities that block the police or sheriffs from telling federal authorities about undocumented immigrants in their custody.

In an announcement at the White House, Attorney General Jeff Sessions said state and local governments seeking certain law enforcement grants would have to certify that they were complying with a law that bars any official from withholding information from the Department of Homeland Security about a person’s immigration status. Those that are violating the policy could see such grants clawed back, he said.

Mr. Sessions’s appearance was an effort to threaten painful consequences for so-called sanctuary cities, those that decline to cooperate with the federal government in efforts to track and deport undocumented immigrants.

“I strongly urge our nation’s states and cities and counties to consider carefully the harm they are doing to their citizens by refusing to enforce our immigration laws and to rethink these policies,” Mr. Sessions said. “Such policies make their cities and states less safe — public safety as well as national security are at stake — and put them at risk of losing federal dollars.”