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 a 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, including 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.