Gloria Macapagal Arroyo, the former Philippine president, has been charged with electoral fraud after the government rushed to court to prevent her from leaving the country.

The charges, which carry a penalty of up to 40 years in jail, were filed by the electoral commission in Manila, a court official said. The commission asked for a court order barring Arroyo from travel, and a judge will decide whether to issue an arrest warrant.

Arroyo tried to leave the country with her husband on Tuesday, saying she was seeking medical treatment abroad for a bone ailment. She was stopped at Manila airport.

She has denied any wrongdoing and her lawyer Ferdinand Tapacio criticised the government's "indecent haste" and what he said was its "emerging pattern of persecution".

Arroyo's legal spokesman, Raul Lambino, said the case was fabricated. He said his client would await a decision by the supreme court on her petition questioning the government's travel ban.

Last week the court granted Arroyo temporary clearance to travel, but the government refused to let her go. The justice secretary, Leila de Lima, said Arroyo may be intending to seek political asylum abroad.

The charges stem from allegations that Arroyo conspired with officials to tamper with results of 2007 congressional polls to favour her candidates.

Arroyo has been in hospital since her failed attempt to leave the country and it is doubtful she would be taken immediately to jail even if the arrest warrant were issued.

After stepping down last year Arroyo, 64, was elected to the house of representatives and immediately faced at least half a dozen complaints, also alleging she diverted state funds for her campaign effort and benefited from foreign contracts.

The justice department is still investigating the other complaints. Her successor as president, Benigno Aquino, was elected on promises to rid the Philippines of corruption.

Arroyo would be the second Philippine president to face trial. Her predecessor, Joseph Estrada, was toppled on corruption charges by a military-backed revolt in 2001 and sentenced to life in prison, but was pardoned by Arroyo.