Ms. Aldana, who has threatened to resign if the expulsion order stands, said the president needed to obey the Constitutional Court.

“I think it’s fair to say this is a constitutional crisis of the gravest proportions,” Eric L. Olson, a Guatemala expert at the Wilson Center in Washington, wrote in an email, suggesting that Guatemala’s fragile institutions may be unable to withstand the rupture. “The train is veering off the tracks, and it’s not clear who will stop it.”

The United Nations secretary general, António Guterres, said that he was “shocked” to hear Mr. Velásquez had been ordered expelled and that he expected the Guatemalan authorities to treat him “with the respect due to his functions as an international civil servant.”

In an interview, Fernando Carrera, a former foreign minister, said that Mr. Morales’s order reflected “just how lost he is in terms of analyzing the power in Guatemala right now” and that “he’s going to find out he hasn’t got as much power as he thinks he does.”

The anticorruption panel, Mr. Carrera said, “has all the power right now.”

“Congress, the media, civil society, political groups are against him,” he said of Guatemala’s president. “The Constitutional Court will put limits on his authoritarian position.”