After an extraordinary outpouring of public indignation, President Otto Pérez Molina resigned from office and appeared before a judge on Thursday to face accusations that he presided over a massive criminal scheme to defraud his impoverished Central American country.

His resignation, submitted at midnight Wednesday, marked the dramatic culmination of weeks of peaceful protests over a bribery and kickback scheme that has implicated about 100 people, including many high-ranking members of his government.

Starting before dawn and running through a drizzly day , crowds gathered outside the presidential palace, blowing horns and chanting “Yes, we could!” as they celebrated Pérez Molina’s departure. For a country with a history of vicious government repression and weak judicial institutions, the outcome was remarkable.

“This is a triumph of the Guatemalan people, to be able to throw out someone so corrupt,” Miguel Lemus, a 58-year-old embalmer, said as he admired the celebration. “We are exhausted from so much corruption, so many lies, so much demagoguery. This was our moment.”

The sudden toppling of the president, after weeks in which he insisted on his innocence and his intention to stay in office, held a significance that went beyond the sordid facts of a financial swindle. Pérez Molina was a former general who led the most feared branch of a military that routinely massacred citizens during nearly four decades of civil war. About 200,000 civilians died, the vast majority at the hands of the government. He helped negotiate the peace agreement that ended the conflict, but also represented a political culture in which leaders lived above the law.

Guatemalan ex-President Otto Perez speaks with journalists at the end of a hearing at the Supreme Court in Guatemala City on Thursday. (Johan Ordonez/AFP/Getty Images)

“This is huge,” said a senior U.S. State Department official who was not authorized to speak publicly. “This is the first time in Guatemala’s history that a sitting president has basically been forced to answer to justice.”

The Guatemalan Congress on Thursday swore in Vice President Alejandro Maldonado to serve until Pérez Molina’s term ends in January. Maldonado took over after the resignation in May of Vice President Roxana Baldetti, now in prison for allegedly receiving $3.7 million in bribes. Guatemalans are to vote Sunday in previously scheduled elections to choose a president to take office early next year.

[Past coverage: Guatemalan Congress clears way for arrest of president in corruption case]

During a radio interview Thursday morning, Pérez Molina described himself as calm but doubted that he would get a fair hearing. He said he considered the accusations “unjust,” but chose to resign and face them rather than cause “confrontation or violence” by holding onto power.

He arrived at the courthouse to jeers of “Thief! Thief!” and bit his fingernails while prosecutors outlined the case against him. Investigators alleged that he and several senior officials participated in a conspiracy to receive millions in bribes in exchange for letting companies evade customs taxes.

The wide-ranging investigation by the attorney general's office and the International Commission Against Impunity in Guatemala, formed by the United Nations nearly a decade ago and funded by several countries, including a $5 million annual contribution from the United States. Led by a Colombian prosecutor, the group has relied on wiretaps and tracked bank records to understand how illicit money moved through shell companies into the hands of government officials.

As the scandal has grown, so have the protests demanding Pérez Molina’s ouster. Students from the most progressive public university marched side by side with those from conservative private schools. Indigenous peasants, business executives and Catholic Church leaders all responded with outrage as they learned of the alleged crimes. When the congressional vote came this week to decide whether Pérez Molina would retain his presidential immunity from prosecution, even his own party abandoned him.

“We don’t have medicine in the hospitals. The children don’t have books in their schools. And throughout society there aren’t any jobs and the president hasn’t done anything to help. They’ve just stolen from the people,” said Maria Elena Aquino Gomez, 38, as she sold flags in the plaza. “Guatemala is alive. We’re not dead. And we’ll continue fighting for our liberty.”

Pérez Molina was expected to spend Thursday night in jail.