ISLAMABAD (Reuters) - Pakistan’s top court on Wednesday warned the military and intelligence agencies they must not exceed their mandate and meddle in politics, an apparent rebuke over their handling of Islamist protests in 2017.

FILE PHOTO: Paramilitary soldiers stand guard outside the Supreme Court building in Islamabad, Pakistan January 29, 2019. REUTERS/Saiyna Bashir/File Photo

The judges’ comments were a rare public ticking off for the powerful armed forces, which have ruled for nearly half of Pakistan’s history and have in recent years been criticized for resuming a more active role in politics.

The army denies interfering.

The Supreme Court was investigating the so-called “Faizabad protest”, which saw a hardline Islamist group paralyze the capital Islamabad accusing a minister of blasphemy.

But the inquiry also looked at the role of security agencies, including ending the standoff through mediation.

Seven people were killed and nearly 200 wounded when police initially tried but failed to remove protesters.

The military is widely seen to have disagreed with civilian authorities over how to handle the protests. The unrest had weakened the previous Pakistan Muslim League-Nawaz (PML-N) government, which had fallen out with the armed forces.

Slideshow ( 2 images )

The army’s role came under criticism after video footage shared on social media showed a senior officer from the military-run Inter-Services Intelligence (ISI) spy agency giving cash to Islamist protesters after a deal was struck to end the blockade.

‘DON’T EXCEED MANDATE’

“The involvement of ISI and of the members of the Armed Forces in politics, media and other ‘unlawful activities’ should have stopped,” Supreme Court Justices Mushir Alam and Qazi Faez Isa said in their verdict.

“Instead when (protest) participants received cash handouts from men in uniform, the perception of their involvement gained traction.”

The Supreme Court also criticized the military’s influential media wing, the Inter-Services Public Relations (ISPR), for commenting on political matters such as the contested 2018 election, where the military was accused of helping Prime Minister Imran Khan into power.

“The Constitution emphatically prohibits members of the Armed Forces from engaging in any kind of political activity, which includes supporting a political party, faction or individual,” the justices said.

“All intelligence agencies ... and the ISPR must not exceed their respective mandates.”

There was no immediate response from the military and intelligence agencies, though in the past the ruling party said the army and government acted together over the 2017 protests.

The judgment urged provincial and federal authorities to monitor and prosecute those advocating hate and extremism, such as the Tehreek-e-Labaik (TLP) group that rose in popularity by championing Pakistan’s harsh blasphemy laws.

TLP leaders have in recent months been mostly arrested or detained after they staged further protests and urged the overthrow of the army chief over the Supreme Court’s acquittal of a Christian woman, Asia Bibi, from blasphemy charges.