The Lahore High Court's order came as authorities blocked almost every entry point to Islamabad on Wednesday, with more than 20,000 police and paramilitary forces deployed to try to thwart a major anti-government rally.
"Pakistan Tehreek-e-Insaf (PTI)and Pakistan Awami Tehreek (PAT)are restrained from launching a march/sit-in in Islamabad in any unconstitutional way keeping in view sensitivity of independence day and (the) current uncertain situation in the country," PTI's lawyer Ahmad Owais said in Lahore quoting from a short order by a three-judge panel headed by Justice Khalid Mehmood.
Interior minister Chaudhry Nisar Ali Khan told a press conference in Islamabad "the court's order will be fully implemented."
"Any political party or a group which wants to hold a march should approach the concerned district administration for permission, which will decide if the the purpose of march is legal and constitutional," he added.
Major roads were barricaded with shipping containers and police used excavators to dig up smaller roads in Islamabad, a day before two opposition protest marches are due to converge on the capital.
Imran Khan and Canada-based preacher Tahir-ul-Qadri, who heads PAT, plan to march on the city on Thursday, Pakistan's independence day, to demand Prime Minister Nawaz Sharif resign and call fresh elections.
Both Khan and Qadri, who led mass demonstrations in Islamabad early last year to urge electoral reform, allege that the May 2013 general election was rigged.
By late Wednesday afternoon only the highway to the airport remained open and even there shipping containers were on standby ready to be moved into place.
The heavily-guarded "red zone", home to parliament, the president and prime minister's residences and foreign embassies, was already sealed with containers, barbed wire and concrete blocks.
Mobile phone services were shut down in the red zone on Wednesday -- a common practice on sensitive occasions in Pakistan aimed at stopping militants using cell phones to detonate bombs.
The city streets were largely deserted on Wednesday, with almost all offices and shops closed.
The government on Wednesday asked the Supreme Court to set up a panel of judges to investigate claims of rigging in last year's general election -- a move announced by Sharif late on Tuesday to try to ease political tension.
The judicial probe was a key demand of Khan, who leads the country's third largest party, but he rejected Sharif's proposal and demanded he step down.
Sharif's landslide general election victory in May 2013 saw Pakistan's first ever handover of power from one civilian-led government to another after a full term, in polls that local and foreign observers called credible.
In his television address on Tuesday, the 64-year-old prime minister said economic progress had been made under his government but the opposition groups' protests would reverse the gains.
Khan and Qadri, who says he is struggling for an "interim national government" consisting of technocrats and experts, have announced they will merge their marches.
Tension has gripped parts of the country since last week, with running clashes between police and supporters of Qadri in the eastern city of Lahore over several days leaving at least one protester dead.
The government for its part has rejected the allegations of vote-rigging and accuses the opposition groups of attempting to obtain by force what they could not achieve through democratic means.
Punjab provincial law minister Rana Mashhood told AFP that more than 1,000 Qadri and Khan activists had been detained in recent days on suspicion of inciting or perpetrating violence.
Get Breaking news, live coverage, and Latest News from India and around the world on NDTV.com. Catch all the Live TV action on NDTV 24x7 and NDTV India. Like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.