Supporters of Pakistan's former prime minister Nawaz Sharif hold up his photo and chant slogans outside a court in Lahore. File picture: K.M. Chaudary/AP

Islamabad - Pakistan's opposition parties have gained ground in by-elections for three dozen seats in the national parliament and regional assemblies, officials said on Monday, in a setback to Prime Minister Imran Khan.

An opposition alliance led by the party of former prime minister Nawaz Sharif won more seats in the national parliament than Khan and his allies in Sunday's polls, elections authorities said.

The by-elections indicate a dip in popularity for Khan, just two months after his Movement for Justice party took over following victory in national polls on July 25.

The by-elections were held for 11 seats in the national parliament and 24 in provincial legislatures, which were vacated by those MPs who won more than one constituency in the national polls.

An individual can contest more than one parliamentary seat under Pakistan's constitution, but can keep only one.

Sharif's Pakistan Muslim League party won four seats in the national parliament and is ahead in the battlefield province of Punjab, Election Commission of Pakistan spokesman Altaf Khan said.

Khan's party also won four national seats but was behind the opposition groups in overall results, the spokesman added.

Political analysts say Khan's popularity has suffered due to tough decisions his government has had to take to tackle an economic crisis, including seeking a bailout loan from the International Monetary Fund (IMF).