GUATEMALA CITY (AP) — A Guatemalan judge issued an order to detain President Otto Perez Molina in a government corruption scandal that has thrown the country into turmoil.

Attorney General Thelma Aldana told Canal Antigua television late Wednesday that Judge Miquel Angel Galvez granted her request for the order. The president will have to appear before the judge on crimes of illicit association, fraud and receiving bribe money in a widespread customs fraud ring in which the vice president has already been jailed and faces charges.

Perez Molina's attorney, Cesar Calderon, told The Associated Press that the president will appear voluntarily and declare before the judge as soon as they have confirmed the order was issued.

He won't be arrested because he is cooperating with the process.

Galvez will decide the next step based on the president's testimony, which could include stripping him of his position, jailing him or maintaining his job and freedom during the judicial process.

Perez Molina, 64, has maintained his innocence and vows to face the legal process. No formal charges have been filed.

He is under an order not to leave the country, and on Tuesday congress lifted his immunity from prosecution in what is widely seen as an unprecedented blow against entrenched corruption and impunity in this Central American nation. Each step in the process is a first, as no sitting president in Guatemala has been prosecuted for a crime, though some have faced corruption charges after leaving office.

The corruption scandal, uncovered by prosecutors and a U.N. commission probing criminal networks in Guatemala, involved a scheme known as "La Linea," or "The Line," in which businesspeople paid bribes to avoid import duties through the customs agency. The ring is believed to have defrauded the state of millions of dollars.

The scandal has already claimed the job of former Vice President Roxana Baldetti, whose ex-personal secretary was named as the alleged ringleader. Baldetti resigned May 8 and is currently in jail awaiting trial on accusations she took millions of dollars in bribes.

Protesters fill the streets almost daily over the scandal, demanding not only that Perez Molina step down but that next Sunday's presidential elections be postponed. He says delaying the vote would be against the law.

Perez Molina is constitutionally barred from seeking re-election, and whoever becomes his successor would take office in January.

Those voting against Perez Molina in Congress included members of his own ruling party.

Business leaders, Guatemala's National Council of Bishops and even the government comptrollers' office have all urged Perez Molina to step down.