"If any personnel of the Armed Forces indulges in any form of politicking or tries to manipulate the media he undermines the integrity and professionalism of the Armed Forces."
That was stated in a posting on the website of the high court on Wednesday.
Pakistani intelligence agencies appear to have played a role in protests against blasphemy in the capital Islamabad in 2017.
Back then, it took several weeks for the tense atmosphere to calm down. The protests were led by a then little-known group called Tehreek-e-Labaik Pakistan (TLP). Violent clashes led to a military-brokered deal at the expense of the lives of at least six people. Also, videos showing what appeared to be troops handing out cash to the protesters helped fuel speculations that they were backed by the military, Presstv reported.
The court statement, which was related to the events of Islamabad, also pointed to the constitution of Pakistan that "emphatically prohibits" members of the armed forces from "engaging in any kind of political activity." The government as well as the chiefs of the army, air force and navy were ordered by the Supreme Court to show due response to any constitutional violation in that regard.
Blasphemy laws in Pakistan have raised concerns among activists and civil society members who say the laws are often exploited by extremists or those who want to settle personal scores.
Hundreds of cases of criminal blasphemy are filed across Pakistan each year. Dozens of people, including lawyers, defendants and judges, have been murdered in Pakistan over blasphemy allegations since 1990.
Elsewhere in the statement, the court spelled out curbs on free speech, giving a serious warning to the intelligence agencies.
"All intelligence agencies... and the (military's media wing) must not exceed their respective mandates. They cannot curtail the freedom of speech and expression."
"Those who resort to such tactics under the mistaken belief that they serve some higher goal delude themselves."
Local media have complained about pressure in the run-up to general elections in July 2018.
The Committee to Protect Journalists said in a report released September last year that the army had "quietly but effectively, set restrictions on reporting."
The military has ruled Pakistan through various coups for nearly half the country’s history since it gained independence in 1947.