Islamabad - Pakistan's federal law minister has resigned, acceding to a key demand made by thousands of protesters who have blocked a major highway into the Pakistani capital for weeks, the state radio broadcaster reported.

An agreement has been signed that would see the demonstrators in Islamabad and other cities disperse, Interior Minister Ahsan Iqbal told the Islamabad High Court during a hearing on Monday, ending a weeks-long standoff that threatened to escalate into countrywide violence.

"On the assurance of the Chief of Army Staff, we are calling off the sit-in," Muslim scholar and protest leader Khadim Hussain Rizvi told a crowd of around 2,500 demonstrators in Islamabad on Monday, AFP news agency reported.

The agreement would also see all protesters who were arrested during the sit-in, which began on November 8, be released within three days.

The government will also take responsibility for paying for any damage caused to both public and private property during the protest.

An inquiry will also be ordered into a government security crackdown on Saturday which saw thousands of riot police fire tear gas, rubber bullets and water cannon in an attempt to disperse the protesters.

Demonstrators fought back with stones, sticks and metal rods, and were able to beat back the authorities.

At least five people were killed and more than 217 - mostly members of the security forces - wounded in those clashes.

Minister accused of 'blasphemy'

Law Minister Zahid Hamid had been accused by clerics of committing blasphemy due to a change in the wording of an oath taken by parliamentarians in the South Asian country.

The protesters, led by Rizvi and other scholars, perceived the change in wording as representing a softening of the state’s position against members of the Ahmadi sect, who are not permitted to identify themselves as Muslims in Pakistan.

The oath was hastily amended back to its original wording, but protesters held the capital under siege for weeks, demanding that Hamid resign from the cabinet.

According to the agreement signed on Monday, the government will also make public an internal inquiry into how the wording of the parliamentary oath was changed.

The Tehreek-e-Labbaik Pakistan (TLP) political party, led by Rizvi, has also agreed not to issue any religious edicts [fatwas] against Hamid.

Blasphemy is a sensitive issue in Pakistan, and certain forms of it can carry the death sentence. Increasingly, those accused of blasphemy have also been subjected to violent attacks by mobs and charged protesters.

Since 1990, at least 73 people have been killed over alleged blasphemy, according to an Al Jazeera tally. They include those accused of blasphemy, members of their families, lawyers who have defended them and judges.

Asad Hashim is Al Jazeera's Web Correspondent in Pakistan. He tweets @AsadHashim.