Supporters of Pakistan's former President and head of the All Pakistan Muslim League political party, Pervez Musharraf, chant slogans during a protest rally against his arrest orders in Karachi April 18, 2013. Pakistani Police arrested former military ruler Pervez Musharraf and confined him to his opulent farm house April 19, 2013. (Athar Hussain/Reuters)

Pakistani police arrested former military ruler Pervez Musharraf and confined him to his opulent farmhouse Friday in a case he has called “politically motivated,” centering on his 2007 suspension of the constitution and mass firing of senior judges.

The former autocrat’s arrest, after he dramatically fled from court Thursday to avoid detention, pits an increasingly assertive judiciary against a powerful military leadership that considers Musharraf one of its own, even if he is no longer well liked among the brass.

If successfully prosecuted, he would be the first former army chief to go to prison in Pakistan’s 65-year history, which includes long stretches of military rule and coups such as the one Musharraf launched to gain power in 1999.

While some political analysts predicted a destabilizing battle between the courts and the army if the retired four-star general is put on trial, others hope for a clean and quick resolution — preferably one that avoids further humiliating Musharraf, whose return to Pakistan last month to run for prime minister has proved disastrous.

A smooth exit would ease tensions in the tumultuous nation as it heads into elections on May 11 that will bring an unprecedented handoff of power between elected governments.

“Some say if it opens a Pandora’s box, so be it,” military analyst Ejaz Haider said of the prospect of a Musharraf trial on what amounts to treason charges. “But a more politic thing to do would be, instead of dragging this whole thing on, to not physically punish the man but punish him symbolically and therefore punish symbolically all the usurpers and abettors.”

The case also is sure to draw in other leaders in the civilian and military branches who were entwined in Musharraf’s imposition of emergency rule during his futile bid to cling to power.

“It was not his sole effort,” said Khalid Ranjha, a former law and human rights minister under Musharraf. “There is a skeleton in everybody’s cupboard, unfortunately. . . . He is being scapegoated. And many of us are hiding our own vices in his prosecution.”

Although the firing and mass arrests of judges did subvert the constitution, the actions were authorized at the time by the Parliament and a reconstituted Supreme Court, Ranjha said. “It is bad, certainly an offense, but he is not the only one who has done it,” he said.

Gen. Ashfaq Kayani, the current army chief and former spy agency director, was part of Musharraf’s inner circle at the time. The military has kept its distance from the fracas so far, in line with Kayani’s recent declarations that the military should not play a role in politics.

Musharraf and his new political party, the All Pakistan Muslim League, say he is a victim of judicial bias.

“These allegations are politically motivated, and I will fight them in the trial court, where the truth will eventually prevail,” Musharraf said in a Facebook posting Friday.

Officials declared Musharraf’s residence on the edge of Islamabad a “sub-jail,” meaning he is effectively under house arrest. The former president’s attorneys are battling to get him bail, but even if they do, he cannot leave Pakistan because the government has also put him on an “exit control list.”

Musharraf returned to his homeland after four years in exile in London and Dubai, determined, he said, to “save” it. The army leadership quietly let him know it considered his campaign unwise because his life would be at risk.(The military itself has avoided commenting on Musharraf.)

Now that Musharraf faces the prospect of prison — or death, if convicted of treason — military commanders may try to broker a deal to send him packing rather than create turmoil, some observers said.

Commanders would not accept the jailing of their former colleague at arms, said Faisal Rehman Malik, a veteran broadcaster here. “It would totally disgrace the military,” he said. “Maybe he would be told, ‘You’ve come, you did great, and we will give you a safe exit. Just leave.’ ”

Attempting to put the best spin on what proved to be a publicity debacle, Musharraf’s attorneys assert that Musharraf did not “escape” from the Islamabad High Court during Thursday’s hearing. Rather, they said, he was following standard procedures to seek bail from a higher court.

But the presiding judge, Shaukat Aziz Siddiqui, said it amounted to a flight from justice and added another charge against Musharraf.

On Friday, Pakistan’s Senate, sitting in a limited session, passed a resolution demanding that Musharraf be tried for abrogating the constitution. All major contenders for prime minister in the upcoming elections have piled on, urging punishment.

“I am sure there is a great desire to take Musharraf by the nape of the neck and rub his face in the dust,” Haider said. “But better to put closure on this chapter in Pakistan’s life.”