In ordering Mr. Velásquez out, Mr. Morales is also openly defying the United Nations and the United States, which have repeatedly supported the prosecutor’s decision to focus the panel’s work on tackling corruption.
“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.”
United Nations Secretary General António Guterres said 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.”
Two years ago, an investigation by Mr. Velásquez and Ms. Aldana into a customs fraud conspiracy led to the fall of then-President Otto Pérez Molina, who resigned after 20 weeks of relentless street protests that displayed remarkable power by outraged citizens.
Mr. Pérez Molina’s support peeled away at the end of his term and he is now in jail, fighting a slate of corruption charges related to the customs scheme and other actions under his government.
Whether Guatemalans will flood the central square with the same determination to hold Mr. Morales to account is uncertain, but the reaction was quick from supporters of the anticorruption battle.
“The same sensation as in the old days of the coups d’état,” wrote the prominent journalist Juan Luis Font on Twitter.
“You commit crimes and you blow up one of those who is investigating,” wrote Gabriel Wer, one of the organizers of the protest movement in 2015. “Wherever you look, this is unacceptable. Jimmy has to resign.”
But there was support for the president’s expulsion order among the far right.
“We have to put undesirable foreigners in their place: out,” wrote Ricardo Ruiz Méndez, an activist with military ties. He has conducted a steady harassment campaign by filing lawsuits against officials in the attorney general’s office.
Mr. Morales became Guatemala’s president after he won the election at the end of 2015 on the slogan, “not corrupt, nor a thief.” A one-time television comedian, he swept into office as an outsider and political neophyte, an incongruous conduit for the hopes of Guatemalans who had reached a breaking point over the impunity of their corrupt politicians.
Hope abounded that the surge of protests that had united the country would help push through the legal changes needed to hold accountable the corrupt members of Guatemala’s political and economic elites. And at first Mr. Morales appeared to support the changes, particularly a judicial overhaul that was to be their centerpiece.
But the effort sputtered as opposition gathered force. Legislators, who are beholden more to donors than to political parties, passed a few laws but watered them down.
The judicial overhaul foundered in Congress. And the powerful business community, which had declared that it was time for an end to corruption, pushed back when new corruption cases swept up the owners of powerful companies.
When Mr. Velásquez and Ms. Aldana announced an investigation that implicated the president’s son and brother in a scheme to falsify receipts, Mr. Morales stopped cooperating with the anticorruption commission, although he did not try then to block the investigation.
The 10-year-old United Nations panel, the International Commission against Impunity in Guatemala, known by its Spanish initials as Cicig, has been at the heart of the effort to strengthen Guatemala’s rule of law. Its international prosecutors work alongside members of the attorney general’s office, giving Guatemalan prosecutors the support to take on cases against powerful figures who would have walked free in the past.
Without a strong ally at the head of commission, Ms. Aldana will be left to take on the anti-corruption cases on her own.
As rumors swirled this past week that Mr. Morales might seek to remove Mr. Velásquez, social media erupted in the prosecutors’ defense. Many Guatemalans, including some of president’s subordinates, have said there is no going back.
Among them is Juan Francisco Solórzano Foppa. Born to leftist guerrilla parents who fought in the country’s civil war, Mr. Solórzano Foppa is a different sort of revolutionary: He is Guatemala’s tax collector.
“I feel that there are a lot of people with the desire to make changes,” he said, speaking before the expulsion order on Sunday. “I think that is possibly the biggest — I don’t know if it’s the legacy or the biggest lesson — of 2015 and the protests in the plaza. I think that people lost the fear of expressing themselves and saying what they think freely.”
At 34, Mr. Solórzano Foppa is one of several high-ranking officials in the Morales government who have begun to push back against the business elites and a political class that have long exercised control for their own ends. He came to the tax agency last year from the attorney general’s office where, as the director of criminal analysis, he helped prepare the customs fraud case that forced Mr. Pérez Molina, the former president, to resign.
Ambassador Todd D. Robinson of the United States, who has been a visible supporter of Cicig and of the attorney general, said before the latest crisis that the 2015 protests had been “lightning in a bottle.” Breaking down old structures and building strong new institutions, he said, would not be straightforward.
“What you’re seeing now is the empire striking back,” Mr. Robinson said. “The corrupt networks, the political and economic elites, have regrouped, they are trying to protect themselves. I would say the battle is being joined. I’m optimistic about the outcome, but I don’t think the outcome is a given.”
In an interview before the Sunday order expelling him, Mr. Velásquez warned that the work he and Ms. Aldana had done was under threat. “I think we are still at very grave risk,” he said. “If the rules of the game don’t change, then the fight against corruption will not bear fruit.”
And he suggested then that his investigations could reach to the top of Guatemala’s power structure. He recalled how some business leaders had come to see him to argue that his corruption fight would hurt economic growth.
“‘It’s enough’ — that’s what they say,” he said, describing the conversations. “‘We have learned. It’s O.K.’ Some have dared to ask me at times, ‘How far will you go?’”