Attorney General William Barr pleaded with the chief justices in Oregon and Washington not to adopt sanctuary policies for their courthouses, saying the states already are releasing dangerous migrant criminals onto their streets.

Mr. Barr, in a stern letter last week, pointed to several recent Seattle-area cases in which gang-connected immigrants who are in the country illegally were accused of vicious murders, including one in which a high school student was pummeled to death with a bat then chopped to pieces with a machete.

And he warned that U.S. Immigration and Customs Enforcement officers and Border Patrol agents are free to make arrests in public areas of courthouses, suggesting the two states’ attempts to expand their sanctuary policies to cover courtrooms will have limited effect.

“Under the Supremacy Clause of the United States Constitution, such rules cannot and will not govern the conduct of federal officers acting pursuant to duly enacted laws passed by Congress,” he said in the letter, which also was signed by acting Homeland Security Secretary Chad F. Wolf.

The letter is the latest salvo in an ongoing battle between the Trump administration, which wants to more strictly enforce immigration laws, and local officials who want to defy that enforcement by announcing safe spaces where they won’t let ICE do its job.

In this case, Oregon’s Supreme Court has adopted a policy precluding ICE officers from arresting illegal immigrants on the property of the state’s courthouses. Washington is pondering a similar move.

They are siding with immigrant-rights activists who say witnesses might be scared into not showing up for important criminal trials if they fear they might be arrested by ICE.

Homeland Security officials dismiss such scenarios, saying ICE officers aren’t on fishing expeditions when they go into the courts, but rather have particular targets in mind — either criminals or fugitives who have lost their immigration court hearings yet are defying deportation orders.

ICE does have a policy of not making arrests at hospitals, schools and churches. But the agency says courthouses are actually good places to make arrests, since those inside already have gone through security and there’s no chance of an armed encounter between an officer and an unruly immigrant who is in the U.S. without permission.

Besides, they say, when individuals on trial are released by the local officials at the courthouse, it makes sense for ICE to be on hand to pick them up rather than later try to track them down in the community, where armed resistance is more likely — and where ICE officers are likely to find other immigrants who are in the U.S. illegally in the vicinity to arrest and deport.

Sanctuary city supporters say they will cooperate when ICE has a judicial arrest warrant signed by a federal judge.

But Mr. Barr and Mr. Wolf, in the new letter, say that’s a misunderstanding of how the immigration system works. They say federal law allows for an administrative warrant to detain and arrest immigrants in the U.S. without permission, and that’s what ICE officers carry with them.

“Administrative arrest warrants while civil in nature are issued based on probable cause, carry the full authority of the United States, and should be honored by any state or local jurisdiction,” they wrote.

Mr. Barr’s signature on the letter with Mr. Wolf is significant. During the Obama administration, ICE had wanted to make a similar joint stand against sanctuary cities, but then-Attorney General Eric H. Holder Jr. refused to join in, siding with the anti-ICE localities instead.

A similar courtroom sanctuary fight is playing out in Massachusetts, where a federal judge ruled in June against ICE being able to make arrests, upholding a state law.

Judge Indira Talwani, an Obama appointee, acknowledged it may be safer to make arrests at the courthouse, but she said that isn’t enough to justify allowing them.

She said federal law doesn’t specifically authorize courthouse arrests on civil warrants or detainers, the government cannot abrogate those existing strictures.

Mr. Barr and Mr. Wolf did not address the Massachusetts situation in their letter.

Massachusetts is also the site of another fight over a local judge facing federal alien harboring charges after she let an immigrant who was in the U.S. illegally leave out the back door of the courthouse to avoid ICE officers she knew were waiting to make an arrest in the public area of the courthouse.