Media playback is unsupported on your device Media caption Orla Guerin reports on the protests that have caused chaos in Pakistan

The Pakistani government has reached a deal with cleric Tahirul Qadri to end his mass protest near parliament in Islamabad, the two sides say.

Mr Qadri wanted the government to resign ahead of elections due in May. The government agreed to dissolve parliament before 16 March.

Pakistan was thrown into crisis on Tuesday by the protests and a court order to arrest PM Raja Pervez Ashraf.

Analysts say that Mr Ashraf is unlikely to be arrested imminently.

The head of Pakistan's anti-corruption agency has refused an order by the Supreme Court to arrest Mr Ashraf for allegedly taking bribes.

Fasih Bokhari of the National Accountability Bureau said investigations had not produced enough evidence to justify an arrest.

Mr Ashraf denies accepting bribes when he approved power generation projects as minister for water and power in 2010.

Cheers

Mr Qadri signalled on Thursday that his four-day protest would end later in the day.

Analysis The government's agreement with self-styled reformist Tahirul Qadri is basically a face-saver for the cleric. He found himself isolated when forces across the entire political spectrum came together denouncing any attempts to derail the system or allow outsiders to dictate terms. The agreement concedes none of his major demands, despite the cleric selling it to his mesmerised followers on Islamabad's Jinnah Avenue as a victory. Contrary to Mr Qadri's fiery demands, both the government and the election commission stay. The revolutionary cleric has merely gained personal concessions - for example some meetings will be held at the Lahore headquarters of his Minhajul Quran organisation and he will be among political leaders consulted in the setting up of an interim government some time in March.

Talks began in the afternoon when a delegation of cabinet ministers and government members entered the bullet-proof container where he has been holed up since Tuesday with thousands of his supporters gathered alongside.

Information Minister Qamar Zaman Kaira told the AFP news agency that the talks were intended to resolve the stand-off, which has paralysed much of the centre of the capital.

His supporters, who have braved cold and heavy rain, reportedly broke into cheers and danced in the street at news of the dialogue.

"We have reached an agreement," Mr Qadri told his supporters said after the deal was reached. "Allah granted us a victory and now you can go home."

However, the BBC's M Ilyas Khan in Islamabad says the deal concedes none of the cleric's major demands and merely allows him to save face.

Under the terms of the deal, the government will dissolve parliament ahead of a a scheduled date of 16 March so that elections, due in May, can take place within 90 days. They have also agreed to discuss electoral reforms.

The government also agreed that the caretaker administration, which normally precedes elections, would be chosen in consultation with all parties.

However, Mr Qadri's demand that the army be consulted on the structure of the interim administration was rejected.

His march from Lahore to Islamabad culminated in a mass rally on Monday evening.

Clashes briefly erupted on Tuesday but the mass protest has been largely peaceful.

The cleric has said he wanted the military and judiciary to be involved in installing a caretaker government to oversee the forthcoming elections.

But he suffered a setback on Wednesday when the leader of the main opposition, the Pakistan Muslim League, refused to back his protests.

There has been speculation that Mr Qadri may be fishing for a role for the military and the judiciary when it comes to the appointment of a caretaker government to oversee over the forthcoming elections.