GUATEMALA CITY -- Guatemala's highest court issued a ruling Wednesday blocking President Jimmy Morales' decision to unilaterally end a U.N. anti-corruption commission.

The commission, known by its Spanish initials as CICIG, has angered Morales by investigating him, his sons and his brother on accusations of corruption, which they deny.

Guatemala's Constitutional Court overruled Morales' decision after all-night deliberations on five appeals against the president's cancellation of the agreement with the United Nations.

Hours later, Guatemala's Supreme Court announced that it would let a petition by a group of lawyers to strip the Constitutional Court justices of their immunity from prosecution advance to the nation's congress.

Supreme Court spokesman Mario Siekavizza said late Wednesday the lawyers were accusing the constitutional justices of interfering in the president's foreign policy decisions. The congress has the power to lift the justices' immunity and Morales and his allies control a majority of the votes.

It was not immediately clear what could happen if the nation's top court was suddenly open to investigation.

Morales has argued the commission had violated Guatemala's sovereignty and violated the rights of suspects.

Given the government's refusal to guarantee the commission's security, the U.N. has withdrawn the commission's members.

U.N. spokesman Stephane Dujarric said the United Nations would not comment on the court's ruling, calling it an "internal legal issue." And he said managing the commission, including the return of its personnel, is up to its chief, Ivan Velasquez.

Dujarric said Secretary-General Antonio Guterres has made clear that the U.N. expects Guatemala's government to respect its commitment for the commission to continue working until September 2019, and that includes "ensuring the safety and security of all staffers."

The court has tussled with Morales before over the commission, though he has sometimes tried to ignore its rulings. The court has said the commission's mandate is valid through 2019.

Guatemala's human rights prosecutor, Jordan Rodas, said Morales' administration has to obey the new ruling.

"The government is under obligation to comply," said Rodas, who presented one of the appeals to the court. "If it doesn't obey, that is a whole other matter, and would constitute a coup, because the cornerstone of the rule of law is respect for the judicial branch."

During its 11 years operating in Guatemala, CICIG has pressed corruption cases that have implicated some 680 people, including top elected officials, businesspeople and bureaucrats. The commission said in November that it has won 310 convictions and broken up 60 criminal networks.

The commission participated in investigations that forced former Vice President Roxana Baldetti and President Otto Perez Molina to step down from office in 2015 to face fraud and corruption charges.