KABUL, Afghanistan — Afghan President Hamid Karzai on Thursday pardoned and ordered the release of an Afghan woman serving a prison sentence for having sex out of wedlock after she was raped by a relative.
Karzai's office also said the woman and her attacker agreed to marry. That would reverse an earlier decision by the woman, who had previously refused a judge's offer of freedom if she agreed to wed the rapist.
Thursday's statement said Karzai decided to forgive the rest of the woman's sentence after hearing from judicial officials. It's not clear how much time the woman has served.
The plight of the woman, identified as Gulnaz, was highlighted in a documentary blocked by the European Union because it feared the women profiled would be endangered by its release.
Thousands of people signed a petition urging Karzai to release her.
Gulnaz's lawyer, Kimberly Motley, told the BBC she hoped the government would now allow Gulnaz the freedom to choose who 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," Motley said.Sesame Street arrives in Afghanistan
The woman, now 21, was jailed two years ago for adultery after she was raped by her cousin's husband. She became pregnant following the attack in 2009 and her baby daughter was born behind bars. When her pregnancy brought the crime to light, she was, like her attacker, convicted and jailed for the crime of adultery by force.
She was initially sentenced to two years' imprisonment, but on appeal, this was increased to 12 years. A further appeal last week saw that cut back again to three years.
Gulnaz's attacker received a 12-year prison term, later reduced on appeal to seven years.
Her case has drawn attention to the challenges still faced by Afghan women, 10 years after the overthrow of the Taliban regime that banned women from almost all work and education.
With foreign combat troops set to return home by the end of 2014, some activists inside and outside Afghanistan fear that women's rights may be sacrificed in the scramble to ensure the West leaves behind a relatively stable state.
Human rights campaigners have condemned her conviction, and the court's decision that she could go free if she married her attacker, which she later agreed to. He is still married to her cousin, but under Afghan law can take a second wife.
This requirement for her release has now been lifted, said her lawyer Kimberley Motley, of law firm Motley Legal, although she could not comment on whether Gulnaz would reconsider her decision to marry him.
"The fact that the court eliminated the portion of the sentence that says she has to marry this man is definitely something that supports the Elimination of Violence against Women law which was signed by the government," Motley said earlier this week.
"Once President Karzai chooses to grant her clemency, which I am very confident of, that will... set precedent and will show his support for the Elimination of Violence against Women act and his support for Afghan women."
That law was passed more than two years ago, but the United Nations warned last week that there was still a "long way to go" in implementing it, and only a small number of cases have been prosecuted under the Act.
Female victims of rape and abuse can find themselves accused of "moral crimes," and like Gulnaz, face heavy sentences, the United Nations found.
Some such offenses, such as running away from home, are not technically crimes under Afghan law, but judges can interpret the law to cover them, Motley said.
Slideshow: Afghanistan: Nation at a crossroads (on this page)
Motley said she believed Gulnaz's appeal was already setting a precedent for some moral crimes cases.
"Hopefully they can use this case... as an example to argue their particular cases in court," she said of defense lawyers.
Motley delivered a petition with nearly 5,000 signatures, collected in less than a week, to Kabul's Presidential Palace on Sunday, demanding Gulnaz's immediate release.
Hundreds more signatures had been added by early Monday, some with strong words of condemnation attached.
"The whole world is watching and every decent person would be disgusted by this and other gross injustices, when the victims are punished instead of the perpetrators just because they are female," one signatory to the petition wrote.
Reuters, The Associated Press and msnbc.com staff contributed to this story.