ISLAMABAD — Pakistani President Pervez Musharraf announced his resignation on Monday in the face of looming impeachment charges, ending a turbulent nine years in power for the key US ally.


The former army chief, who seized power in a bloodless coup in 1999, had been under huge pressure to quit before the coalition government launched the first impeachment proceedings in Pakistan's 61-year history.


Celebrations erupted in several cities after the announcement, with people dancing in the streets, although the country's political future -- as well as Pakistan's role in the US "war on terror" -- now is far from certain.


"After viewing the situation and consulting legal advisers and poltical allies, with their advice I have decided to resign," a grim-faced Musharraf , wearing a sober suit and tie, said in a televised address to the nation.


"I leave my future in the hands of the people."


Musharraf said he would hand his resignation to the speaker of the national assembly, or lower house of parliament, later on Monday.


There had been days of reports of negotiations that would allow him to stand down without facing legal action, and it was not immediately clear what would happen to him next.


Musharraf, who became a vital ally of the United States after the September 11 attacks in 2001, made the surprise announcement during a long and winding speech in which he said any impeachment charges against him would never stand.


He gave a lengthy defence of his time in power, saying that he had helped establish law and order, improve democracy and human rights and burnish the country's international stature.
"On the map of the world, Pakistan is now an important country, by the grace of Allah," he said.
The president insisted he had always led in "good faith," especially in facing economic problems and the threat of Islamic militancy, and said that his opponents had made "false allegations" against him.


"Pakistan first has been my philosophy," he said.


"Unfortunately, some elements acting for vested interests levelled false allegations against me and deceived people," Musharraf said.


"They never realised that they could be successful against me, but they never thought how detrimental it would be for the country."


Musharraf's popularity slumped last year amid his attempts to oust the country's chief justice and then during a wave of Taliban suicide bombings that killed more than 1,000 people, including former premier Benazir Bhutto.


He imposed a state of emergency in November last year to force his re-election to another five-year term through the Supreme Court, but his political allies were trounced at the February polls.


The coalition of parties which won the February election, led by Bhutto's Pakistan People's Party, finally overcame months of divisions and agreed to impeach Musharraf on August 7.
It piled on the pressure with no-confidence votes in Pakistan's four provincial assemblies last week. Then on Sunday it said it had drawn up impeachment charges and would lodge them in parliament this week.


The charges reportedly included violation of the constitution and gross misconduct.
Officials say that Musharraf's aides have been in talks with the coalition, brokered by Saudi Arabia, the United States and Britain, to allow him to quit in return for indemnity.
Musharraf's spokesman had repeatedly denied in recent days that he was about to quit.
But a lack of apparent support from Pakistan's army, which he left in November, apparently made other options -- including dissolving parliament or even declaring another state of emergency -- impossible.


Speculation over Musharraf's fate intensified overnight when US Secretary of State Condoleezza Rice said that granting asylum to Musharraf was not currently under consideration by the United States.


"That's not an issue on the table, and I just want to keep our focus on what we must do with the democratic government of Pakistan," Rice said.


Western allies want Pakistan to resolve the crisis over Musharraf so it can deal with the fight against Taliban and Al-Qaeda militants in the tribal areas bordering Afghanistan, where nearly 500 people have died in the past week.