A vehicle transporting former President and military strongman Pervez Musharraf, leaves Islamabad High Court after the court ordered his arrest, in Islamabad, on April 18, 2013. (T. MUGHAL/EPA)

Pervez Musharraf, an unlikely candidate for Pakistan’s prime minister and certainly the country’s only former military ruler to have appeared twice on Jon Stewart’s talk show, took political theater to a new level Thursday with a wild flight from justice that transfixed the nation and ended with the fugitive holed up in his farmhouse savoring a cigar.

Early Friday, Pakistan police said they arrested Musharraf overnight and brought him before a judge in Islamabad, the Associated Press reported.

The weird saga began with Musharraf, who seized power in a 1999 coup and strode the world stage as Pakistan’s top general and president for nine years, appearing in an Islamabad court to face treason charges related to his tenure in office. The case centers on his imposition of emergency rule in November 2007, when he placed scores of judges under house arrest, deposed the chief justice of the Supreme Court and sparked protests that eventually ended with his self-exile.

Hearing the case Thursday, Islamabad High Court Justice Shaukat Aziz Siddiqui essentially declared Musharraf a terrorist, revoked his bail and ordered him arrested. It was the latest setback for the former ruler, who returned home with great bravado last month to run in a historic general election next month, with the proclaimed goal of saving his troubled nation.

Arresting and confining judges “is not an ordinary act, rather it is an act of terrorism,” Siddiqui wrote in his order. “This shameful act lowered the honor, prestige and status of the country” in the eyes of the international community, he added.

Rather than turning himself in, Musharraf retreated to an armored sport-utility vehicle, which took off with a member of his security detail hanging on to its side. Only days before, the former strongman had vowed that he was not afraid to face jail or death for returning to Pakistan.

The footage was aired repeatedly on the country’s numerous fractious cable news channels — which exist thanks to Musharraf’s decision to deregulate the broadcast media, a move that many analysts credit with stimulating democratic debate in the country.

Musharraf, 69, also has been disqualified from running for Parliament in four constituencies. His party alleges bias on the part of district election commissions, which are made up of members of the judiciary, a community in which he is singularly unloved.

After the Islamabad hearing, Musharraf’s convoy, escorted by paramilitary troops known as Rangers, headed to the capital’s outskirts, where he has a luxurious, well-fortified farmhouse.

While his attorneys went to the Supreme Court to attempt to secure bail for him, reports circulated that Musharraf had been placed under house arrest. Ahmed Raza Kasuri, his attorney, denied that and rejected suggestions that the former leader had fled from court.

“There were hundreds of Rangers in Musharraf’s security escort,” he said. “He went with them and came back with them. It was not an escape.”

Kasuri, talking to reporters outside the farmhouse, said his client was not worried about his fate.

“Musharraf is relaxed, confident and happy,” the lawyer said. “We were sipping coffee, and he was smoking a cigar.”

The former four-star general’s return put Pakistan’s powerful military in an awkward spot. Its leaders have vowed not to interfere with the election, but neither do they want to see Musharraf in the public stocks. Military spokesmen could not be reached for comment throughout the day.

The turn of events Thursday seemed to seal Musharraf’s non­viability as a candidate and renewed questions about the onetime army commando’s motives in taking the gamble to return to Pakistan.

“I think he came back against all advice,” said Khalid Ranjha, who served as law minister under Musharraf and remains his defender. “Maybe he came as an adventure, being a commando.”

Musharraf certainly never lacked for ego. He wrote a self-serving autobiography, “In the Line of Fire,” while still in office, and promoted it on Stewart’s show in 2006. The general-in-exile returned in 2011 to talk about Osama bin Laden and geopolitics with the late-night king of fake news.

Thursday’s escapade stirred gibes on Twitter, where Pakistani commentators competed for laughs.

“Pervez Musharraf is [the] Veena Malik of Pakistani politics,” wrote journalist Shiraz Hassan, referring to a striving young actress known for publicity stunts.

“What?” retorted Marvi Sirmed, an activist and columnist. “What makes you humiliate Veena Malik like this?”

Shaiq Hussain contributed to this report.