But removing the president’s immunity has enormous symbolism in a country long divided by class and race and where impunity for the powerful was the rule in a system fueled by corruption.

“It sends a very powerful message both to Guatemalans and to other countries in the region,” said Adriana Beltrán, a senior associate at the Washington Office on Latin America. “That the justice system can be made to work, even against those that have been historically deemed untouchable. That you can have the rule of law and respect due process and human rights.”

Many watching the events over the past months say they mark a broader change.

“I would say that Guatemala today is not the Guatemala from before April,” Ms. Beltrán said.

The case against Mr. Pérez Molina, which forced the resignation of his vice president, Roxana Baldetti, in May, was brought by a United Nations-backed commission of independent prosecutors that has been working alongside the Guatemalan attorney general’s office for almost a decade. The commission has brought down a series of corrupt officials, developing complex cases using wiretaps and other evidence.

Its work has strengthened Guatemala’s own prosecutors, hampered by limited resources.

The political turmoil has played out against the backdrop of an election campaign that has been caught up in the protests. Voters go to the polls on Sunday, although no candidate is expected to win 50 percent, and a second round between the top two candidates is set for Oct. 25.

Mr. Pérez Molina is not eligible for re-election and his term ends on Jan. 14. Leading academics and civil society groups had asked for Sunday’s election to be postponed, arguing for time to put electoral reforms in place.

Manuel Baldizón, a wealthy businessman, has led the polls for much of the campaign. His running mate is himself embroiled in a corruption inquiry, and the urban middle classes that have flocked to the protests have made it clear that they consider Mr. Baldizón part of the same corrupt system, shouting: “It’s your turn next.”

Jimmy Morales, a comedian who is running as an outsider, has moved up in the polls. Sandra Torres, a former first lady, is in third place.