Afghan President Hamid Karzai has pardoned a rape victim who was jailed for adultery, after she apparently agreed to marry her attacker.
A government statement said she agreed to the marriage, although her lawyer said she did not wish to marry him.
The woman, named as Gulnaz, gave birth in prison to a daughter who has been kept in jail with her.
Senior Afghan officials told the BBC the government put no preconditions on her release.
"President Karzai tasked the minister of justice to go and talk to Gulnaz to see what she wants. During her meeting with the minister, she said she will marry the attacker only if her brother marries the attacker's sister," Emal Faizay, a spokesman for President Karzai, told the BBC.
"This is a decision by her. I can confirm that there is no precondition set by the Afghan government."
Gulnaz's lawyer told the BBC she hoped the government would allow Gulnaz the freedom to choose whom to marry.
"In my conversations with Gulnaz she told me that if she had the free choice she would not marry the man who raped her," said Kimberley Motley.
The case has drawn international attention to the plight of many Afghan women 10 years after the overthrow of the Taliban.
Human rights groups say hundreds of women in Afghan jails are victims of rape or domestic violence.
Earlier this month, Gulnaz said that after she was raped she was charged with adultery.
"At first my sentence was two years," she said. "When I appealed it became 12 years. I didn't do anything. Why should I be sentenced for so long?"
The most recent appeal saw her sentence reduced to three years.
'Marriage with conditions'
Some 5,000 people signed a petition for Gulnaz's release. News of her pardon came in a statement from the presidential palace.
It said a meeting of the judiciary committee had "discussed the issue of rape... and the issue of her imprisonment".
"As the both sides [Gulnaz and the rapist] have agreed to get married to each other with conditions, respective authorities were tasked to take action upon it according to Islamic Shariah [law]," it said.
"The president ordered the office of administrative affairs and the secretariat of the council of ministers to make the decree of Gulnaz's release."
The attack on Gulnaz was brought to light by her pregnancy. Her attacker - her cousin's husband - was jailed for 12 years, later reduced on appeal to seven years.
Her story was included in a European Union documentary on Afghan women jailed for so-called "moral crimes" - however, the EU blocked its release.
The EU said it decided to withdraw the film - which it commissioned and paid for - because of "very real concerns for the safety of the women portrayed".
The EU's Ambassador and Special Representative to Afghanistan, Vygaudas Usackas, said on Thursday he was "delighted" to hear Gulnaz was to be freed.
"Her case has served to highlight the plight of Afghan women, who 10 years after the overthrow of the Taliban regime often continue to suffer in unimaginable conditions, deprived of even the most basic human rights," he said.
"While we applaud the release of Gulnaz, on the orders of President Karzai, it is the hope of the European Union that the same mercy that has been extended to Gulnaz is applied to all women in similar circumstances."
Human rights workers criticised the EU for withdrawing the documentary, saying the injustice in the Afghan judicial system should be exposed.
Half of Afghanistan's women prisoners are inmates for "zina" or moral crimes.
The BBC's Bilal Sarwary, in Kabul, says recent cases of violence against women are embarrassing for the Afghan government.
Many Afghan women rights activists say there must be an end to the culture of impunity and police must punish all those behind violence against women, he adds.