(CNN) -- Pervez Musharraf recently returned to Pakistan after five years in exile, determined to face down his challengers in the courtroom and make a sensational return to politics in time for the May 11 election.
But his grand plan has turned to a disaster following a week that the former president would rather forget.
On Tuesday, election officials barred Musharraf from running for a seat in parliament. By Friday he was formally arrested -- the first time that has happened to any former chief of the Pakistani army -- amid claims he illegally placed senior judges under house arrest during a period of emergency rule he imposed in 2007.
Later that day he was transferred to a guest house at Islamabad Police HQ where he can be held for a maximum 48 hours before he appears in court to face charges relating to the detention of the judges. At that point he could get bail, go to jail or return to house arrest at his villa. Most analysts expect the house arrest option.
The ex-military strongman still has to face two separate other cases dating from his time in power. The first relates to claims he did not do enough protect the life of Benazir Bhutto -- the first woman to be elected prime minister of Pakistan -- after she was assassinated in 2007, just weeks before an election in which she hoped to be returned to office. Musharraf is also accused of ordering his troops to kill Nawab Akbar Bugti, a popular tribal leader, in the volatile province of Balochistan, in 2006.
Last month, Musharraf told CNN that all the charges against him are "trumped up, politicized cases." But he now finds himself under house arrest at his farmhouse compound on the outskirts of Islamabad.
Why did Musharraf bother returning to Pakistan?
Despite the criminal charges awaiting him and the threat of assassination by the country's Taliban extremists, Musharraf arrived in Karachi last month and declared: "I have come to save Pakistan."
Though the party that succeeded him became the first democratically elected government to serve a full five-year term during the country's 65-year history, Pakistan is still beset with problems -- a crippled economy, food shortages, frequent power cuts and a bloody insurgency.
In his absence overseas, the government had frozen the considerable wealth Musharraf had acquired.
According to CNN's Nic Robertson in Islamabad, Musharraf expected a swift return to politics amid plenty of popular support -- but that proved a major miscalculation.
"From day one it didn't happen," said Robertson. "As one of his advisers told us, 'it would have been better if he hadn't come back.' Musharraf anticipated hundreds of thousands of people greeting him at the airport when he landed. It turned out to be hundreds.
"Then there were the legal cases: charges of treason, of being involved in the Bhutto murder and of putting judges under house arrest. In all those cases the judges really went after them aggressively.
"Musharraf had expected them to hold off until after the election. That didn't happen.
"Then his apparent miscalculation in the election itself -- he was barred by the election commission from challenging for four different seats. Now he's not able to leave the country and under house arrest. The reality is the advice he appears to have been given about the level of popular support he still has in Pakistan was erroneous."
What level of support does Musharraf have?
Musharraf's popularity began to wane in 2007 after he suspended the chief justice of the Supreme Court for "misuse of authority." The move resulted in protests and accusations that he was attempting to influence a court decision on whether he could seek another term in office.
More than six years on and some Pakistanis would be happy to see the return of the ex-military ruler, hoping his leadership could help restore order to a country riddled with political division and plagued by extremist violence. But others will point to the many enemies in the final years of his presidency, notably among the judges he detained.
The Pakistani Taliban vowed to send a death squad to hunt down the former president if he returned to the country, although Musharraf has admitted he has been living under threat of death since September 11, 2001, when he supported the American war on terror and fought against the Taliban.
Musharraf also revealed last week that his government secretly signed off on U.S. drone strikes within its borders, but only if there was no time for Pakistan's military to act against al Qaeda targets. This is the first time a top Pakistani official, past or present, has admitted publicly to such a deal.
"He said it wasn't a blanket agreement -- he agreed to perhaps several of these types of drone attacks -- but until now absolutely no word, no hint of this, only ever denials that there were ever any green lights," said Robertson.
Can Musharraf count on support from the military?
As the former army chief, Musharraf will have retained support and influence within Pakistan's powerful military. "Most people here think the army won't let him go to jail and won't tolerate him being under house arrest for long," said Robertson.
"However they will not do anything rash. They'll exert their influence behind the scenes to secure a favorable outcome. I think for now the legal process continues apace."
What's next for Musharraf?
More court appearances. After appearing before a magistrate Friday, Musharraf returned home where he is being held under house arrest, according to his lawyer, Ahmed Raza Qasoori.
Musharraf will continue to seek bail in the case, Qasoori said. However, an attempt on Thursday to appeal the Islamabad court's decision at the Supreme Court appeared to have so far been unsuccessful. To further complicate matters, Qasoori claimed the Islamabad High Court judge who ordered Musharraf's arrest is one of the judges whom Musharraf is alleged to have had detained in 2007 and therefore should have recused himself from the case.
Are there implications for Pakistan?
"The judiciary has been emboldened, though they are widely perceived to operate a political bias," said Robertson. "But in the end we are seeing small steps towards democracy in Pakistan. Ultimately a strong and unbiased judiciary is a good check on political corruption and excess."
But an editorial Friday in The Nation, an English-language newspaper, took a more critical view of events this week. "All segments of society, supporter or opponent, official or non-official, high or low, are watching keenly to ascertain just how Pakistan will deal with the first of its former dictators to go on trial.
"Adding further spice to the case was the total inaction shown by the police in putting him under arrest that had been specifically ordered by the IHC (Islamabad High Court). As he came out of the court room, he sped off to his villa ... in a bullet-proof vehicle, guarded by his personal security, with the police and rangers playing the part of silent spectators."
Referring to the provisional administration in place until after next month's election, it added "the shameful reality is the utter lack of cooperation and indifference shown by the caretaker setup in Musharraf's trial, though it is simply carrying on with the tradition set by its predecessor governments."
CNN's Jethro Mullen contributed to this report.