WASHINGTON — A federal judge on Thursday blocked President Donald Trump’s executive order aimed at dismantling the Education Department and ordered officials to reinstate thousands of fired employees in a ruling that marked at least a temporary setback for the president and his plans.

The decision from Judge Myong J. Joun of U.S. District Court for the District of Massachusetts was a preliminary injunction, meaning it will remain in force until the case is resolved or a higher court overturns it.

The injunction was requested by a pair of school districts in Massachusetts, the American Federation of Teachers and 21 Democratic state attorneys general who sued Trump in March to block his executive order and reverse a massive round of layoffs. Joun agreed with their argument that the actions equated to an illegal shutdown of the agency, which only Congress can abolish.

“The record abundantly reveals that defendants’ true intention is to effectively dismantle the department without an authorizing statute,” Joun wrote in his order.

Madi Biedermann, the Education Department’s deputy assistant secretary for communications, said the administration would immediately challenge the decision while taking aim at the judge.

“Once again, a far-left judge has dramatically overstepped his authority, based on a complaint from biased plaintiffs,” Biedermann said in a statement. “President Trump and the Senate-confirmed secretary of education clearly have the authority to make decisions about agency reorganization efforts, not an unelected judge with a political ax to grind.”

Joun, an Army and National Guard veteran, was a board member of the American Civil Liberties Union of Massachusetts before President Joe Biden appointed him to the federal bench in 2022.

In March, he temporarily ordered the Trump administration to release $65 million in teacher-training grants that had been suspended as part of Trump’s efforts to root out diversity, equity and inclusion policies. While an appeals court upheld that order, the Supreme Court in April overruled Joun.