Guatemalans elected a former television comic as president in 2015 on promises he would be honest, unlike his reviled predecessor. But on Sunday, in a move that sent Guatemala lurching toward chaos, he ordered the head of a United Nations-backed anticorruption panel expelled after it began moving against him.

The decision by President Jimmy Morales to go after a panel he had once readily accepted was a head-spinning turn for Guatemala, which is regarded as one of Latin America’s most corrupt countries but which also appeared to be making progress toward accountability.

Hours after the president’s expulsion order, Guatemala’s Constitutional Court temporarily blocked it. The ruling will force Mr. Morales to back down or to defy the country’s top judges.

The anticorruption panel is led by Iván Velásquez, a Colombian prosecutor who has spearheaded a series of political corruption inquiries since he arrived in Guatemala four years ago. Mr. Velásquez and Attorney General Thelma Aldana said late Friday that they would seek to strip Mr. Morales of his immunity from prosecution, alleging that he had failed to report anonymous contributions to his campaign.