Guatemalan President Otto Perez Molina has resigned hours after a judge issued a warrant for his arrest.
Prosecutors accuse Perez Molina of masterminding a scheme to defraud the customs service of millions of dollars. He denies the allegations.
On Tuesday, Congress stripped him of his immunity from prosecution, a first in the Central American nation.
A spokesman said Perez Molina had decided to step down to "confront the proceedings against him".
Bribery allegations
Perez Molina's resignation comes just days before Sunday's presidential election, in which he was barred from standing under constitutional rules.
Vice-President Alejandro Maldonado is expected to govern until the new president is sworn in on 14 January.
Maldonado has only been in the post since mid-May, when his predecessor Roxana Baldetti resigned.
Baldetti is accused of involvement in the same corruption scheme which Mr Perez Molina allegedly masterminded.
Investigators say the scheme, dubbed La Linea, or The Line, involved businesses paying bribes to government officials and custom officers in return for being allowed to evade import duties.
Mass protests
The corruption scandal has triggered a series of mass protests in Guatemala and widespread calls for Mr Perez Molina to resign.
But until Wednesday night, the president had stood firm, saying he would serve out his term.
His spokesman said Perez Molina had handed in his letter of resignation just before midnight local time.
Congress still has to approve his resignation before it comes into force.
Local media said Perez Molina's current whereabouts were unknown.
On Tuesday, a judge barred him from leaving the country "as a precautionary measure".
Earlier this week, Perez Molina said he would be "very respectful and submit himself to the rule of law".
(BBC)