Pakistan's authorities have struck a deal with a hard-line Islamist party to end a protest over the acquittal of a Christian woman convicted of blasphemy.
As part of the deal, proceedings will begin to bar Asia Bibi from leaving the country.
The government will also not prevent protesters legally challenging the Supreme Court decision to release her.
Asia Bibi was convicted in 2010 of insulting the Prophet Muhammad, but was acquitted earlier this week.
The ruling enraged some in the majority-Muslim country.
Hardliners who support Pakistan's blasphemy laws have been taking to the streets since Wednesday's ruling.
Pakistani Information Minister Fawad Chaudhry told the BBC, "We had two options: either to use force, and when you use force people can be killed. That is not something a state should do... We tried negotiations and (in) negotiations you take something and you leave something."
He defended the agreement against allegations the government was capitulating to extremists:
"We need to take steps against extremism, we need to take steps against such kind of violent protesters and we need to come up with a permanent solution. Right now this is not a cure. This is firefighting, what we are doing. The cure is the real thing and our government is committed to the cure."
He clarified that the decision on whether or not to bar Asia Bibi from leaving the country would be made by a court, and added the government would "take all steps necessary" to ensure Asia Bibi's safety.
What's in the deal?
It was reached between the government and the Tehreek-i-Labaik (TLP) party, which led the mass protests, local media report.
Under the agreement, as well as beginning legal proceedings to put Asia Bibi on a list which would ban her from leaving Pakistan, the government will also not block a review petition filed against the verdict.
The deal also envisages that all protesters arrested since Asia Bibi's acquittal will be released, and any violence towards them will be investigated.
Protest in Faizabad coming to an end after agreement between clerics and govt pic.twitter.com/5DeQvagVKm— Secunder Kermani (@SecKermani) November 2, 2018
In return, the TLP is asking its supporters to stop the protests and disperse peacefully.
The authorities earlier said that Asia Bibi was scheduled for release later this week.
Speaking to the BBC this week, her lawyer Saiful Mulook said she would need to move to a Western country for her own safety. Several countries have offered her asylum.
What was Asia Bibi accused of?
The trial stems from an argument Asia Bibi, whose full name is Asia Noreen, had with a group of women in June 2009.
They were harvesting fruit when a row broke out about a bucket of water. The women said that because she had used a cup, they could no longer touch it, as her faith had made it unclean.
Prosecutors alleged that in the row which followed, the women said Asia Bibi should convert to Islam and that she made offensive comments about the Prophet Muhammad in response.
She was later beaten up at her home, during which her accusers say she confessed to blasphemy. She was arrested after a police investigation.
On Wednesday though the Supreme Court acquitted her, saying that the case was based on flimsy evidence and her confession was delivered in front of a crowd "threatening to kill her".
Why is this case so divisive?
Islam is Pakistan's national religion and underpins its legal system. Public support for the strict blasphemy laws is strong.
Hard-line politicians have often backed severe punishments, partly as a way of shoring up their support base.
But critics say the laws have often been used to get revenge after personal disputes, and that convictions are based on thin evidence.
The vast majority of those convicted are Muslims and Ahmadi Muslims, but since the 1990s, scores of Christians have been convicted. They make up just 1.6% of the population.
The Christian community has been targeted by numerous attacks in recent years, leaving many feeling vulnerable to a climate of intolerance.
Since 1990, at least 65 people have reportedly been killed in Pakistan over claims of blasphemy.