Attorney General Jeff Sessions and Homeland Security Secretary John Kelly have defended federal agents who make immigration arrests at courthouses after California's top judge asked them to stop, a letter released Friday states.

Sessions and Kelly sent the letter Wednesday to California Chief Justice Tani Cantil-Sakauye, saying state, county and city policies barring local law enforcement from turning over arrestees for deportation have compelled federal agents to arrest immigrants at courthouses and other public places.

Courthouses are a safe place for federal agents to make the arrests because visitors are typically screened for weapons, the letter says.

"While these law enforcement personnel will remain mindful of concerns by the public and governmental stakeholders regarding enforcement activities, they will continue to take prudent and reasonable actions within their lawful authority to achieve that mission," it says.

The back-and-forth came amid a feverish debate across the country over the relationship between local law enforcement agencies and immigration officials.

Many jurisdictions have refused to collaborate with immigration authorities after President Donald Trump signed executive orders to step up deportations.

In response, the administration has warned that those counties and cities run the risk of losing federal funding.

In their reply, Sessions and Kelly took issue with Cantil-Sakauye's accusation, writing that "stalking" is a crime where a victim is being followed or harassed.

"The arrest of persons in a public place based upon probable cause has long been held by the United States Supreme Court as constitutionally permissible," they wrote.

Cantil-Sakauye said Friday she was disappointed that courthouses would not be added to the list of "sensitive areas" where immigration officials don't make deportation arrests. Those areas include schools, churches and hospitals.

"I appreciate the prompt letter and their admission that they are in state courthouses making federal arrests," Cantil-Sakauye said in a statement. "However, making arrests at courthouses, in my view, undermines public safety because victims and witnesses will fear coming to courthouses to help enforce the law."