A supporter of Imran Khan dances near the parliament building in Islamabad on Wednesday. Photograph: B.K. Bangash/AP

After leading almost three weeks of street protests demanding fresh elections in Pakistan, the former cricketer Imran Khan sent his elected MPs back to parliament on Wednesday in a sign that the country's political crisis may be heading towards a resolution.

The leader of Pakistan Tehreek-e-Insaf (PTI) last week said he no longer recognised the legitimacy of parliament and announced all his MPs would resign as part of his efforts to topple the government.

Khan claims last year's election was rigged against him, although independent election observers do not think irregularities would have changed the overall result.

The long campaign to force the resignation of the prime minister, Nawaz Sharif, has, at times, prompted fears the army would step in and derail Pakistan's weak democracy.

But the return of the MPs and the dwindling number of PTI supporters on the streets outside the parliament building suggested Sharif's government had regained the initiative.

PTI leaders also began talks with a government-appointed "political jirga" to negotiate a face-saving end to the crisis, which will probably include a commitment to fresh electoral reforms.

The change in fortunes followed violent clashes between protesters and police over the weekend that left three dead and hundreds injured.

But analysts said Khan's biggest roadblock was the united front shown by Pakistan's other parties who on Tuesday pledged their support for Sharif remaining in power.

"He has been critically isolated and now he is running out of options," said political commentator Zahid Hussain.

"He is still hoping against hope that the army will come in but there is now no question of an army takeover."

During many of his regular speeches in recent weeks, Khan promised his supporters that a "third umpire" would ultimately force Sharif to resign – a thinly veiled reference to Pakistan's army which has brought down civilian governments in the past.

Khan was accused of working with the army by one of his key allies, veteran politician Javed Hashmi, who parted ways with Khan during the demonstration.

Addressing parliament, senior PTI leader Shah Mehmood Qureshi strongly denied there had been any unconstitutional plan to subvert democracy, insisting that "we are protesting to save parliament, not to destroy it".

His insistence that the protests had always been peaceful and that "not even a flowerpot was broken during the protests" was mocked by other members of parliament.

The normally immaculate area around Constitution Avenue in the heart of Islamabad's government quarter in fact looks like a war zone. Trees were set alight by protesters during fighting with police and the gates to the grounds of parliament were smashed open to allow thousands of protesters to pour in and set up a camp.

Khan, who has spent most of the past three weeks living on the streets in a converted sea container on wheels, did not attend the debate. His cause was also set back when some of his party workers were identified among protesters who temporarily seized the offices of the state broadcaster.

Nor was there any clarification on whether the PTI MPs, many of whom were said to be unhappy about the demand for them to sacrifice their seats, would finally resign from parliament.

On Wednesday the crowds that at times had been as large as 50,000 people had dwindled to a few thousand.

Many of them did not appear to be PTI supporters but followers of Tahir-ul-Qadri, a populist cleric who led a parallel protest in the capital against the entire political system, which he claims is hopeless corrupt.

Addressing his longsuffering supporters on Wednesday, Qadri continued to insist the prime minister would have to step down. But the chances of that happening appeared ever more remote.