Islamabad, Pakistan (CNN) -- A day after he made a swift exit from an Islamabad court when a judge revoked his bail, former Pakistani President Pervez Musharraf appeared before a magistrate on Friday and was formally placed under house arrest.
The development is the latest setback to Musharraf since the former military ruler returned to Pakistan last month to fight a series of court cases against him and re-enter the country's turbulent political scene by seeking to run in upcoming elections.
His arrest also highlights the increased willingness of Pakistan's judiciary, who clashed with Musharraf during his time in power, to pursue cases against high-profile figures previously considered to be untouchable. No former Pakistani army chief has previously been arrested and detained.
Amid a long-running fight with the judiciary, Musharraf resigned as president of Pakistan in 2008 after nine years in power and went into exile the following year, living in London and Dubai. He came back to Pakistan last month under heavy security.
But so far, his return does not seem to be going according to plan. Earlier this week, Pakistani election officials barred Musharraf from running for a seat in parliament in elections next month, a decision his lawyer has said he will challenge.
That decision appears to have emboldened members of the judiciary, many of whom have bitter memories of their treatment by Musharraf during his time in power.
But the legal drama concerning a former head of the army appeared to be fueling concerns about how the powerful Pakistani military might respond, with the country under the management of a caretaker government ahead of the elections next month.
"The fears that the army might sharply react if the cases are taken to their logical conclusion hang in the air," The Nation, an English language newspaper, wrote in an editorial Friday. "But Pakistan is now irrevocably destined for a democratic transition, and on this, all institutions agree."
Accused of detaining judges
The Islamabad High Court had ordered Musharraf's arrest on Thursday in a case in which he is accused of illegally ordering the detention of senior judges in 2007. The high court said in its ruling that it was an "act of terrorism" to prevent the judges from doing their job.
But he quickly left the building after the judge announced the decision, returning to his farmhouse compound outside the Pakistani capital.
His legal status at that point was unclear. Local media reported he had been placed under house arrest, but the judge's order for his arrest remained outstanding.
On Friday morning, local broadcaster Geo TV broadcast images of Musharraf arriving at a court building accompanied by uniformed police officers and other members of the security forces. Pakistani authorities have provided some of his heavy security detail since his return.
Islamabad police spokesman Naeem Iqbal said officers had formally arrested Musharraf and produced him before a magistrate in court. But Mohammad Amjad, a spokesman for Musharraf's political party said the former president had presented himself in court.
He said Musharraf denies the charges against him and never gave any order to detain or abduct the judges in 2007.
After appearing before the magistrate on Friday, Musharraf was allowed to return to his farmhouse, which has been converted into a "sub jail" 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. An attempt on Thursday to appeal the Islamabad court's decision at the Supreme Court appeared to have so far been unsuccessful.
Qasoori said that Shaukat Aziz Siddiqui, 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. As a result, Qasoori said, Siddiqui should have recused himself from the case.
Siddiqui wasn't immediately available for comment on Friday.
In another step in the process, Musharraf will have to appear in court again next week.
He had previously received bail extensions in the cases concerning him. He was also initially granted "protective" bail to ward off potential arrest when he returned to Pakistan. But the judiciary appears to have taken a more aggressive line than he may have expected, stepping up the pursuit of cases against him.
When asked last week about his fears of arrest, Musharraf brushed the question aside.
A mixed reception in Pakistan
Musharraf was disqualified from contesting elections in Pakistan because of the state of emergency he declared in 2007. Even though he hasn't been tried for that action, the move was ruled an act of treason, making him ineligible to run for office. Musharraf maintains he should not be barred because he has not been convicted of any criminal acts.
Some Pakistanis are 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 he also made many enemies in the final years of his presidency, notably among the judges he allegedly detained.
The Pakistani Taliban vowed to send a death squad to hunt down the former president if he returned to the country, though Musharraf has said he has been living under threats of death since September 11, 2001, when he supported the American war on terror and fought against the Taliban.
The former general became president after a bloodless coup in 1999.
Musharraf's popularity began declining in 2007 after he suspended the nation's Supreme Court chief justice 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.
CNN's Nic Robertson and journalist Nasir Habib reported from Islamabad. CNN's Jethro Mullen reported and wrote from Hong Kong. CNN's Shaan Khan contributed to this report.