Tipping illegal immigrants off to a looming immigration sweep could net sanctuary city leaders jail time, under a new bill announced Monday by Rep. Steve King.

The Iowa Republican dubbed the bill the Mayor Libby Schaaf Act, after the Oakland mayor who alerted California’s Bay Area to an impending sweep earlier this year, in a move that immigration officials said helped hundreds of people escape detection.

At the time, the chief of U.S. Immigration and Customs Enforcement said Ms. Schaaf was essentially acting as a “gang lookout” tipping off lawbreakers when police came through their neighborhood.

Mr. King’s new bill would include a penalty of up to five years in prison for any state or local official who obstructs enforcement of federal laws.

“I want lawless, sanctuary city politicians to hear this message clearly: If you obstruct ICE, you are going to end up in the cooler,” Mr. King said in announcing his bill.

President Trump, a vehement opponent of sanctuary cities, has already called for Ms. Schaaf to be prosecuted.

And ICE chief Thomas D. Homan and Homeland Security Secretary Kirstjen Nielsen have officially petitioned the Justice Department to see if they can prosecute sanctuary city officials.

But Mr. King said there’s some debate about whether current laws make Ms. Schaaf’s behavior in tipping off illegal immigrants criminal.

He said his bill would “remove all doubt.”

Ms. Schaaf, appearing on CNN Monday night, vowed to remain firm in the face of pressure.

“We will not let anyone intimidate us. We will not apologize for those values,” she told the network.

She defended the legality of sanctuary policies, saying local officials have the right to decide how much cooperation to provide to federal officials, and she doubted Mr. King’s bill could withstand scrutiny.

“It’s not possible that legislation like that could be illegal. Sanctuary city policies are legal policies,” she said.

She added that the “warning” she gave was only “general” in nature, and amounted to advising people of their legal rights should they be caught. She doubted anyone managed to escape ICE’s sweep because of it.

“The idea that caused any amount of people to not be apprehended as part of that operation just cannot be true,” she said.