Pakistan's government on Friday introduced legislation to extend the tenure of the army chief in line with a Supreme Court order that it must justify its wish to see the top commander stay on in the job for an extra three years.

The government of Prime Minister Imran Khan approved an extension for General Qamar Javed Bajwa in August, citing a worsening national security situation in the region over its rivalry with India.

More:

But in a surprise ruling, the Supreme Court struck down the extension in November, ordering the government and army to produce legal provisions and arguments on the reasoning behind the move, pitting the judiciary against the government and powerful military.

Pakistan's military has ruled the country for about half its 72-year history and sets defence and security policy and recently has had a role in framing economic policies too.

The army chief usually serves a three-year term.

On Friday, the first day of a new parliamentary session, the government introduced a lower house bill to provide legal cover for Bajwa's extension after managing to win the support of opposition parties, government officials said.

"We are willing to support the legislation if the government follows parliamentary procedures," said Bilawal Bhutto Zardari, the leader of the main opposition party.

The legalisation is expected to be passed by next week, clearing the way for Bajwa in his post until 2022.

During Bajwa's tenure, the opposition has accused the military of meddling in elections and politics to support Khan, while limiting civil liberties and muzzling the media.

The military denies interfering in politics.