The Trump administration has embarked on a border patrol agent recruiting drive and begun aggressive stings to arrest undocumented immigrants amid the president's call for upping deportations.

Standing in its way are so-called sanctuary cities that refuse to detain some potential deportees. Those jurisdictions are fighting back, with two of them asking a federal judge Friday to block President Donald Trump's executive order withholding perhaps billions of dollars from cities and counties that don't cooperate.

San Francisco and its Silicon Valley neighbor, Santa Clara County, are seeking a nationwide ban on enforcement of a Jan. 25 executive order in which Trump declared the sanctuary policies have caused "immeasurable harm to the American people and to the very fabric of our republic."

A victory for the two could reinforce similar policies in some of the nation's largest cities, including New York, Los Angeles and Chicago. It would be another blow to Trump's call to tighten U.S. borders and crack down on those living in the U.S. illegally. He's already lost multiple bids to impose a travel ban against citizens of six mostly Muslim countries.

A win for the city and county would also bolster California's aspirations to lead the so-called resistance against the Trump administration's agenda. This month, the state Senate passed the California Values Act, a measure that would give the entire state sanctuary status by prohibiting its agencies from sharing certain information with U.S. counterparts or detaining individuals on orders from Washington.

"This unconstitutional order cannot be enforced, cannot be applied, cannot exist consistent with law," John Keker, a lawyer for Santa Clara County, argued at the start of Friday's court hearing in San Francisco. "The president doesn't have the power to do it."

Keker called the threat to withhold funding a "gun to the head" of local officials.

U.S. District Judge William Orrick agreed the county and the city have showed they're harmed by the administration's policy, which gives them the right to sue to block it.

The White House and Attorney General Jeff Sessions have chided California and its allies, accusing them of harboring criminals. Sessions said in March that the administration would use "all the lawful authority we have to make sure that our state and local officials are in sync with the federal government."

Sessions told the International Association of Chiefs of Police at a conference in Litchfield Park, Arizona, that the Justice Department was serious about enforcing immigration laws to make the country safer.

"But there are holdouts," Sessions said in Tuesday's speech. "Some mayors and city councils, and even a police chief and a sheriff here and there, are refusing to work with the federal government, choosing instead to protect the criminal aliens who harm public safety. For the sake of your communities, families, and children, work with us."

After Trump issued his executive order, the administration asked Congress to draft a 2017 spending bill that includes a provision to withhold federal funds from states and local governments that shield undocumented immigrants from deportation. Part of the Justice Department's argument against the requests for preliminary injunctions by San Francisco and Santa Clara County is that neither has actually lost any funding yet.

The city and county say the administration's threats have already caused damage. Their residents, especially immigrants, now fear that that local police have been commandeered by U.S. Immigration and Customs Enforcement and will detain and deport them if they seek help in an emergency, they contend.

"On the ground, communities are already experiencing the harm of the executive order," said Jayashri Srikantiah, a Stanford Law School professor who submitted an argument in the case in support of the city and county. "During the floods in San Jose, the undocumented and immigrant communities were reluctant to call law enforcement for fear they'd be turned over to ICE."

ICE agents have executed regional detention and removal programs on a weekly basis to arrest "criminal aliens" en mass. From April 2 to April 6, ICE said it arrested 368 foreign nationals across the country, including in New York City, Denver, Colorado and Washington. One of them was a Guatemalan man who had been released by New Jersey authorities after Camden County declined to honor a detainer request filed by ICE.

While state and local governments can do little to control ICE's detention sweeps, the San Francisco federal judge's ruling could determine whether they can continue to enforce their own laws, even if they contradict White House policy. The city and county contend more than $2 billion in public funding is at stake if the president's order is enforced. They also argue the order is a clear violation of Congress' exclusive right to allocate or withhold public funds, as well as the Constitution's 10th Amendment protecting states from federal overreach.