Pakistan's military has struck back after an unprecedented challenge to its hegemony by the popular Imran Khan and his followers, but the nuclear-armed nation remains caught between its most powerful institution and the man who was once a firm ally.
Khan's arrest on corruption charges earlier this month, which he says was at the behest of the generals, led to violent nationwide protests, attacks on military buildings and on the homes of senior officers, allegedly by the former prime minister's supporters.
There has never been that kind of challenge to Pakistan's military, which has held sway over the country since independence in 1947 with a mixture of fear and respect. It has been in power for three of those decades and has wielded extraordinary influence even with a civilian government in office.
I've seen the fall of Dhaka and of course there was a lot of opposition later, but never of this severityNaeem Khalid Lodhi, an ex-general of Pakistan Army
"I've seen the fall of Dhaka and of course there was a lot of opposition later, but never of this severity," said Naeem Khalid Lodhi, a general who was part of the army's top decision making process as a corps commander, and later held key government posts.
The 1971 fall of Dhaka in what was then East Pakistan and the birth of Bangladesh after defeat by arch-enemy India has been the lowest point for Pakistan's military since 1947.
Populist civilian leader Zulfikar Ali Bhutto took charge after that debacle, holding sway over the army for five years. The generals, however, staged a military coup in 1977, and stayed in power for 11 years. Military ruler Gen. Muhammad Zia-ul-Haq ordered Bhutto hanged.
Khan was released by court order two days after his arrest, but his Pakistan Tehreek-e-Insaf (PTI) party now faces the ire of the military.
Thousands of supporters have been arrested, including Khan's top aides. The government has said those accused of being involved in attacks on its installations will be tried by military courts - a platform typically reserved for enemies of the state.
With Pakistan also grappling with a devastating economic crisis, a showdown between the military and its most popular political leader could push the nation of 220 million to the brink of chaos.
"(The military) is trying to assert raw power by invoking the draconian Army Act against civil society and thereby risks destroying Pakistan’s fragile constitutional system," said Shuja Nawaz, a distinguished fellow at the Atlantic Council's South Asia Center and author of "The Battle for Pakistan".
A spokesperson for the military did not respond to several requests for comment.
While civilian organisations have historically been unable to stand up to the military's might in a country where no elected prime minister has completed a full term, Khan is unlikely to be a pushover.
The larger-than-life 70-year-old is an Oxford graduate, was part of London's smart set in the late 1970s and later led cricket-mad Pakistan to victory in the 1992 World Cup. Famed for his aggressive, never-say-die attitude when he played the game, he seems to have brought that approach into politics.
After years in the wilderness, rival political parties said the military supported his ascent to become prime minister in 2018 while Khan himself blamed the same generals for his ouster last year. The military denies any role in his taking office or his ouster.
Since then Khan has shown an uncanny ability to mobilise crowds and some analysts say he has the support of many in the rank-and-file of the military.
"Khan has weaponised the resentment his followers feel about his removal into a frontal assault on army leaders," said Aqil Shah, an academic and author of the book "The Army and Democracy in Pakistan".
His popularity remains high - well ahead of his opponents, according to local polls - in the run-up to national elections which are due by November this year.
However, Khan is vulnerable on many fronts. If he is found guilty in any of the numerous cases against him, ranging from corruption to inciting terror, it would in all probability disqualify him from participating in the polls.
The army's vast intelligence apparatus will also turn the screws on PTI's leadership, many of whom have already jumped ship because of pressure and fear of retribution, Khan says.
The way forward
Analysts say talks are necessary between Khan, the army and the civilian government of prime minister Shehbaz Sharif to defuse the situation - but there have been no indications of any negotiated settlement.
Khan has dismissed the Sharif government as inconsequential.
Information minister Marriyum Aurangzeb told Reuters that Khan's supporters attacked "sensitive military installations" and that the law would take its course.
Zulfiqar Bukhari, one of Khan's few close aides yet to be arrested, says the PTI has reached out for talks with the military, but had got no response.
"Unfortunately, no one wants to listen," he said.
Some analysts believe Khan will have to placate the generals in some way for him to survive.
Others said the gloves were off and the military would not back down.
"Ultimate power in Pakistan flows through the barrel of the gun," said Shah, the academic. "The military is unlikely to give Khan the off-ramp any time soon."
Husain Haqqani, Pakistan's former ambassador to the United States and currently a scholar at the Hudson Institute in Washington, said the military has lost standing significantly and it will not accept being attacked and taunted.
"The military's power comes from its ability to deploy force, not popularity - Pakistan's generals like being liked but they like being in control even more," he said.