(Reuters) - When hardline Pakistani Islamists signed an agreement with the government this week to end a crippling blockade of the nation's capital, the text of their deal concluded by thanking the army chief who it said had "saved the nation from a big catastrophe".
The effusive praise for General Qamar Javed Bajwa's role as mediator has triggered some concern among moderate politicians and criticism from a judge in Islamabad, where 36 hours earlier the civilian government had called in the army to restore order after police clashed with the entrenched Islamists.
Seven people had been killed and nearly 200 wounded in an unsuccessful police-led operation to clear the Islamist protesters, who accused a government minister of blasphemy.
Instead of sending in troops, General Bajwa requested a meeting with Prime Minister Shahid Khaqi Abbasi on November 26. The next day, the government capitulated and met most of the Islamists' demands, including the resignation of Law Minister Zahid Hamid, who stood down.
A High Court judge issued an order demanding the government explain why the military had helped negotiate the deal on November 27. Judge Shaukat Aziz Siddiqui said the army appeared to be overstepping its constitutional role, which requires it to "act in aid of civilian government when called upon to do so".
Critics worry the military may be meddling in politics - always a concern in a country where the army has repeatedly seized power - rather than simply following the orders of the civilian administration.
"The job of the military is to be subservient to the government's orders," said political analyst Zahid Hussain. "The military's role as facilitator has raised many questions."
A ruling party spokesman said the army and government had acted in consultation and said the army did not balk at government orders. No evidence has emerged to contradict that account. The military itself did not respond to repeated requests for comment.
Zahid said he was resigning "to take the country out of a crisis-like situation", according to state-run news channel PTV.
Tehreek-e-Labaik, a recently formed ultra-religious party that has made punishing blasphemy its main campaign rallying cry, had blocked main roads into Islamabad for nearly three weeks, demanding Law Minister Hamid's removal.
It blamed the minister for a tweak in the wording in an electoral law that changed a religious oath proclaiming Mohammad the last prophet of Islam to the words "I believe", a change the party says amounts to blasphemy. The government put the issue down to a clerical error and swiftly changed the language back.
Insulting Islam's prophet is punishable by death under Pakistani law, and blasphemy accusations stir such emotions that they are almost impossible to defend against.
Last week, the Islamabad High Court had ordered the government to remove the protesters, but not to use firearms.
A clearing operation on November 25 quickly descended into chaos, with protesters armed with iron rods and stones battling police to a standstill and scores on each side hospitalized, after which the government called in the army.
In an order made at a follow-up hearing on November 27, Judge Siddiqui said it appeared that the "role assumed the top leadership of the army is besides the constitution" and "beyond its mandate".
The judge said it was "alarming" that Major General Faiz Hameed had signed the agreement as a mediator. Hameed is a senior member of the powerful Inter-Services Intelligence agency, in charge of counter-terrorism, two senior military officials confirmed.
Ruling party official Jan Achakzai confirmed that Prime Minister Shahid Khaqan Abbasi and army chief General Bajwa had met on November 26, but said the process was consultative and it did not constitute the military questioning orders.
"The army ... suggested the government resolve it through negotiations," Achakzai said, adding that the government, after deliberations, directed the interior ministry to meet the protesters' demands to avert further violence.
"It was affecting the whole country," he said, adding the government had yielded "in the larger interest of peace and maintaining law and order".
Tehreek-e-Labaik leader Khadim Hussain Rizvi gave his account of the army's role in ending the stand-off at a news conference.
"So the general took personal interest and sent his team, saying 'we will become the guarantors, and have your demands fulfilled'," Rizvi told journalists on November 27. "So we said, 'All right. That is what we want'."
The military's press department did not respond to questions about Rizvi's account.
Tensions between the military and the ruling party led by former Prime Minister Nawaz Sharif have occasionally broken out into the open.
Sharif had last year rejected a plan put forward by the army to "mainstream" some hardline Islamist groups into politics, government sources have previously told Reuters, including a forerunner of Tehreek-e-Labaik.
The Islamist party has denied it has any links to the army and the military declined at the time to comment on the report.