RICHMOND, Va. (AP) - Virginia communities that don’t cooperate with federal immigration authorities could be sued over crimes committed by people living in the country illegally under a measure the state Senate approved Monday.

The bill designed to crack down on so-called sanctuary cities comes after President Donald Trump signed an executive order last month to strip funding from such communities. Conservative states across the country have considered a variety of anti-sanctuary city bills since the president’s order, while liberal states have moved to add protections for immigrants in the country illegally.

The bill from Republican Sen. Dick Black would make sanctuary cities liable for crimes committed within their locality. It advanced on a 21-19 vote.

The measure will help prevent the increasingly common practice across the country of localities “flouting” federal immigration law, Black said during debate on the measure. He also said that victims of crimes committed by people in the country illegally often have little recourse and said the bill would fix that.

But several Democrats who spoke against it said it would leave the wrong people on the hook.

“It seems to me you’re asking the taxpayers to pick up something which is not really their responsibility,” Senate minority leader Dick Saslaw said.

Democrats also argued that the bill would be difficult to enforce because it defines a sanctuary city as one that acts intentionally to restrict the enforcement of immigration law.

“I don’t know how you would ever prove that,” said Sen. John Edwards, a Democrat from Roanoke.

The issue of sanctuary cities gained greater prominence after the 2015 killing of 32-year-old Kate Steinle in San Francisco, who was fatally shot while she walked along a popular city pier. A man who had been previously deported and had been released by local law enforcement was charged in her death.

Trump repeatedly mentioned the killing of Steinle during the campaign as he called for a border wall and other measures to curb illegal immigration.

About 300 localities nationwide have sanctuary city-like policies, according to the Center for Immigration Studies, which advocates for lower immigration levels. In Virginia, Arlington and Chesterfield County have such policies, according to the group.

Last week, Mayor Mike Signer said he is considering making Charlottesville a sanctuary city and is looking into ways to add protections for immigrants and political refugees. And on Monday, Richmond Mayor Levar Stoney issued a directive that says the city will promote policies of inclusion for all residents regardless of immigration status. Though it doesn’t label Richmond a sanctuary city, it also says police will not ask individuals for their place of birth or immigration status.

Black’s measure still needs approval from the House of Delegates, which debated a different sanctuary city-related bill Monday. That measure from Del. Charles Poindexter would prohibit localities from adopting “any ordinance, procedure, or policy that restricts the enforcement of federal immigration laws.” The chamber advanced the bill despite opposition from Democrats. It still needs a final vote.

A spokesman for Democratic Gov. Terry McAuliffe said the governor is reviewing the proposals.