A federal judge on Tuesday ruled that the Department of Government Efficiency’s dismantling of the U.S. Agency for International Development was likely unconstitutional on multiple fronts—including the role Elon Musk played to orchestrate it.

The order from Judge Theodore D. Chuang in Maryland directed the team to halt its work to shutter the agency and reinstate access to electronic systems for employees and contractors who were shut out.

He also took aim at Musk himself, spending pages wading through White House comments and social-media posts about the role played by the billionaire, an adviser and close ally of President Trump.

The Trump administration’s lawyers have said Musk is a presidential adviser giving recommendations with no binding legal effect. But Chuang in his ruling pointed out that Musk has continuously acted as DOGE’s de facto head, without having been properly appointed with Senate approval—likely in violation of the Appointments Clause of the U.S. Constitution.

FILE PHOTO: A person holds a sign as activists attend a protest against cuts to government agencies by tech billionaire Elon Musk and his young aides at the cost-cutting Department of Government Efficiency (DOGE), outside the SpaceX’s facility in Hawthorne, California, U.S., March 1, 2025. REUTERS/David Swanson/File Photo

“If a President could escape Appointments Clause scrutiny by having advisors go beyond the traditional role of White House advisors who communicate the President’s priorities to agency heads and instead exercise significant authority throughout the federal government so as to bypass duly appointed Officers, the Appointments Clause would be reduced to nothing more than a technical formality,” wrote Chuang, an appointee of former President Barack Obama .

The injunction deals a blow to one of the earliest moves taken by the Trump administration and DOGE to drastically scale back the size of the federal government.

During its first few weeks, the Trump administration largely dismantled the work of the 10,000-person agency and the thousands of people in nonprofits and other groups who work with it. Its headquarters was closed, its name taken off the building and most of its staff put on paid leave. Employees stationed overseas were ordered to come home within a month.

FILE PHOTO: Elon Musk looks on during the day of a meeting with House Republicans to discuss the Department of Government Efficiency (DOGE) on Capitol Hill in Washington, D.C., U.S., March 5, 2025. REUTERS/Kent Nishimura/File Photo

The case was filed by more than two dozen USAID employees and contractors over the rapid-fire moves to terminate or put on leave most of the agency’s workforce. It argued Musk and DOGE lacked legal authority to dismantle an agency typically under the purview of Congress, both by overstepping the separation of powers and because Musk and his team weren’t properly appointed.

DOGE members “displayed an extremely troubling lack of respect for security clearance requirements” and had full access to highly sensitive personal information kept by USAID, according to Chuang’s order. Chuang also found the White House had likely overstepped its authority in seeking to fully unravel the agency without going through congressional channels.

Lawyers for the government had argued the president and executive branch have the authority to direct the strategy of foreign relations and agency priorities, which they believe extends to the ability to dismantle the U.S. foreign-aid programs.

White House deputy press secretary Anna Kelly called the ruling a “miscarriage of justice” and said the government plans to appeal Chuang’s decision. “Rogue judges are subverting the will of the American people in their attempts to stop President Trump from carrying out his agenda,” she said.

The ruling was one of several setbacks for the Trump administration on Tuesday. In another, U.S. District Judge Tanya Chutkan temporarily blocked the Environmental Protection Agency from terminating Biden administration climate grants that were meant to fund clean-energy projects across the country, saying lawyers for the government hadn’t shown sufficient proof of illegality. She called the government’s claims “vague and insufficient.”

The White House’s latest criticism of what it describes as “activist judges” came just hours after U.S. Supreme Court Chief Justice John Roberts issued a rare public statement chiding President Trump’s calls for the removal of another judge who had ruled against him.

Norm Eisen , executive chair of State Democracy Defenders Fund, one of the groups representing the plaintiffs, called the decision “a milestone in pushing back on Musk and DOGE’s illegality.”

Write to Mariah Timms at mariah.timms@wsj.com