(Adds comment from Massachusetts attorney general)

By Nate Raymond and Scott Malone

BOSTON, April 25 (Reuters) - U.S. federal prosecutors on Thursday charged a Massachusetts judge and court officer with conspiracy and obstruction, saying they blocked an Immigration and Customs Enforcement officer from arresting an illegal immigrant at a 2018 court proceeding.

The move marks the latest skirmish over immigration between President Donald Trump's administration and local governments who have resisted his crackdown. The state's Democratic attorney general called the charges "politically motivated."

The charges target Massachusetts District Court Judge Shelley Joseph, 51, and Massachusetts Trial Court Officer Wesley MacGregor, 56.

They focus on an April 2018 hearing in Newton District Court, outside Boston, where an Immigration and Customs Enforcement officer intended to arrest an unidentified suspected illegal immigrant from the Dominican Republic facing a drug charge.

They described a huddled conversation between the judge and the defendant's lawyer in which Joseph asks, "ICE is gonna get him?" and later says, "I'm not gonna allow them to come in here."

She then arranged for the suspect to be released through the court's rear door while the ICE agent waited in the courtroom's lobby for him to emerge.

Massachusetts U.S. Attorney Andrew Lelling, a Trump appointee, said the case was not intended to send a political message.

"We did not bring this case in response to the public debate over immigration enforcement," he said.

State Attorney General Maura Healey rejected that assertion.

"Today's indictment is a radical and politically-motivated attack on our state and the independence of our courts," Healey said in a statement.

Representatives of the judge and court officer did not respond to requests for comment.

The state Supreme Judicial Court suspended Joseph without pay, but said its move "in no way reflects any opinion on the merits of the pending criminal case."

The charges carry a sentence of up to 20 years in prison.

The suspect has since been caught and is now in federal custody.

Massachusetts' top court in 2017 ruled that state police cannot detain illegal immigrants solely to buy time for federal officials to take them into custody.

One of Trump's top priorities in office has been cracking down on illegal and legal immigration and he has regularly railed against "sanctuary" cities and states that do not cooperate with all aspects of federal immigration enforcement.

Trump earlier this month floated the idea of busing undocumented migrants stopped at the border to "sanctuary cities," a move critics called illustrative of a callous approach to the issue and some Trump allies called impractical. (Reporting by Scott Malone and Nate Raymond; editing by David Gregorio, Cynthia Osterman and Susan Thomas)

Our Standards: The Thomson Reuters Trust Principles.