Guatemala's congress has sworn in a former judge as president while his predecessor has appeared in court over corruption allegations just hours after resigning.
Alejandro Maldonado, a 79-year-old conservative who only became vice president in May, will serve out the rest of Otto Perez Molina's term, handing over on January 14.
Separately on Thursday, a judge - citing a flight risk - ordered Perez to be held in prison while hearings over his alleged role in a customs-corruption scandal continue.
Al Jazeera's Daniel Schweimler, reporting from Guatemala City, said the developments show "how fast and how far Perez has fallen. In the meantime, things have been moving very very quickly here".
Inside Story: Can corruption be wiped out in Guatemala?
The attorney general's office has said it plans to bring charges against Perez for illicit association, taking bribes and customs fraud, though he has not yet been formally charged. The hearing will continue on Friday.
Guatemala will hold elections on Sunday to choose Perez's successor, in a climate of widespread outrage over the corruption scandal and broad rejection of the traditional political elite.
Speaking after taking the oath of office, Maldonado, a former judge on the Constitutional Court, said: "The new government must emerge from the need to inspire citizens' confidence, opening a space in public service for mature and experienced people but also young professionals and social activists."
Congress had earlier voted unanimously to accept Perez's resignation, which he submitted just before midnight on Wednesday after politicians stripped him of his presidential immunity.
Tapped phone calls
As Maldonado was putting on the presidential sash, Perez appeared before the Supreme Court, looking uncomfortable as prosecutors detailed their accusations against him.
Perez, 64, a former military intelligence officer, had been in office since 2012. He was ineligible for re-election and would have handed over power in January.
Perez lowered his eyes as prosecutors played out tapped phone calls they say implicate him in a scheme to defraud the state.
Investigators believe Perez received $3.7m in bribes paid by importers in exchange for illegal discounts on their customs duty, according to Antonio Morales, a prosecutor.
|Prosecutors alleged in the Supreme Court on Thursday that tapped phone calls implicated Perez in a scheme to defraud the state [Reuters]
Roxana Baldetti, Perez's former vice president who resigned in May, has already been charged with taking $3.8m in bribes between May 2014 and April 2015.
"I'm calm and I will face the situation bravely because I've done nothing wrong," Perez told a local radio station before his court appearance on Thursday.
He stepped down after clinging to power through months of mounting protests.
Guatemalans fed up with corruption erupted in celebration outside the Supreme Court early on Thursday on the news of Perez's resignation.
Thousands have hit the streets in protest since the scandal first erupted in April, on a scale never before seen in Guatemala.
Civil war's shadow
The accusations have caused outrage in the Central American country of 15 million people, 53.7 percent of whom live in poverty.
Also the scars are still fresh from a 36-year civil war that ended in 1996, and which has the dubious distinction of being one of Latin America's most violent nations, with about 6,000 murders each year.
The scandal was uncovered by investigators from a UN commission entrusted with fighting high-level corruption in Guatemala, who say they found evidence that Perez orchestrated a scheme dubbed La Linea (The Line), named for the hotline that importers would allegedly call to access a network of corrupt officials.
|The corruption charges have caused outrage in Guatemala, an impoverished Central American country of 15 million people [Reuters]
Investigators say their accusations are based on 89,000 tapped phone calls.
The climate in Guatemala is jubilant but tense heading into Sunday's elections, which will also choose the members of the 158-seat legislature and 338 mayors.
Rights groups have reported cases of political party activists attacking protesters, and some 10 candidates were murdered between March and August.
In a sign of Guatemalans' exasperation with politics as usual, a poll published on Thursday found the leading candidate in the presidential vote is now actor Jimmy Morales.
The poll gave Morales 25 percent support, ahead of the former front-runner, lawyer Manuel Baldizon (22.9 percent), and former first lady Sandra Torres (18.4 percent).
The three candidates will perhaps compete for the two spots in a runoff vote on October 25.
|Ex-vice president Baldetti has already been charged with taking $3.8m in bribes between May 2014 and April 2015 [AP]
Source: Al Jazeera and agencies