ISLAMABAD: Pakistan's Supreme Court on Thursday granted six-month conditional extension to Army chief Gen Qamar Javed Bajwa, in a relief to Prime Minister Imran Khan's government.

A three-member bench of the apex court, headed by Chief Justice Asif Saeed Khan Khosa and comprising Justices Mazhar Alam Khan Miankhel and Mansoor Ali Shah, in its short order directed the government to bring necessary legislation within six months' time, Geo TV reported.

Bajwa's original three-year tenure is set to expire on Thursday at midnight and he can now continue as the Army chief for another six months.

Prime Minister Khan through an official notification of August 19 granted a three-year extension to General Bajwa, citing "regional security environment".

The government withdrew the August 19 orders after the top court's observations in the case and issued a fresh notification which was also rejected by the court on Wednesday.

The unprecedented action by the apex court shook the high echelon of powers as the government scrambled to control the damage.

Khan held an emergency Cabinet meeting to deal with the precarious situation, with Gen Bajwa himself attending the deliberations.

Farogh Naseem, who resigned from his post as law minister on Tuesday to pursue the case, represented Gen Bajwa in the court.