Four years ago, a long-awaited law to protect women and girls from violence, the Law on Elimination of Violence Against Women (EVAW), was finally passed in Afghanistan. In a country where many women and girls are forced to enter and stay in abusive marriages, it seemed a ray of hope. However, in January, a provision in Afghanistan's draft criminal procedure code became the latest in a series of attempts to roll back the already fragile legal protections for women and girls.

The 128-page draft code had undergone a six-year drafting process involving hundreds of hours of meetings and discussion among Afghan justice officials and international advisers on criminal justice, but the version passed by  parliament and sent to President Hamid Karzai for his signature on February 9, 2014 included "relatives of the accused" among a list of people who "cannot be questioned as witnesses" in criminal proceedings. The rule, in Article 26, allowed no exceptions. It would have given the abusers of women effective immunity for their crimes.

The context for this latest drama matters. This is not a strange legislative drafting mishap or an unintended consequence of a poorly thought-through good intention. This comes after a year of frequent and serious attacks on women's rights by the Afghan parliament, government and judiciary.

Not only did that version have an outright prohibition against calling the "relatives of the accused" to testify in criminal proceedings, it also had a very broad definition of the term "relatives." A "relative" was defined as "husband or wife and their ancestors and descendants up to the second generation, mother and father and their ancestors up to the second generation and brother, sister, uncle, aunt and their descendants up to the second generation." In Afghanistan, that could have easily excluded an entire village.

If the provision were left intact, Article 26 would have gutted Afghanistan's new and still tentative protections for women who are victims of domestic violence by silencing a very large potential pool of witnesses to crimes committed against women in the privacy of the family home.

Crimes against women in their homes by family members remain a serious problem. In 2008, research by Global Rights showed (PDF) that 87 percent of a sample of Afghan women reported that they had faced at least one form of abuse in their lifetime, 39 percent said they had been hit by their husband in the last year and 59 percent said they were in forced marriages.

Article 26 of the proposed code violates the underlying aim of EVAW. The law bolstered legal protections for women by, for the first time, criminalizing rape, child marriage and forced marriage and by imposing tough new penalties for domestic violence. The UN has closely tracked the enforcement of EVAW, and the findings offer a mix of both frustration and hope for Afghanistan's women. Its 2013 analysis (PDF) indicates that government enforcement efforts have in many parts of the country been slow, uneven and lackluster, but the UN also reported progress in that both the number of cases of reported violence against women and related cases prosecuted under the law are gradually rising. For example, in 2013, 28 percent more cases of violence against women were registered than in the previous year. However, the number of prosecutions under the new law rose only two percent, suggesting that while the law is having a positive impact, it is far too slow.

So who would want to derail EVAW and why? It is not clear who drafted Article 26 in its present form, but a majority of members of parliament supported it, notwithstanding the negative impact it posed to efforts to protect women from violence.

Besieged by pleas from Afghan activists and a growing number of donor countries not to sign the draft criminal procedure code into law without further amendments, Karzai paused. Officials initially argued that there had been a misunderstanding and that Article 26 would only prevent courts from compelling relatives to testify (but would permit voluntary testimony). Eventually the Justice Ministry conceded that the language of Article 26 suggested otherwise and agreed to revise it.

In late February, Karzai sought to defuse the controversy by signing into law the parliament's version of the code but following it up with a separate presidential decree amending Article 26. The decree clarifies that relatives of the accused are permitted to testify voluntarily. It also allows compelled testimony from anyone who is a "complainant or informant regarding the crime" and slightly narrows the definition of "relatives."

Karzai's revised Article 26 still exempts far too many family members from being called to court as witnesses. The new version of the law exempts grandparents and grandchildren and everyone in between from testifying, including former wives or husbands. Limiting testimony in criminal proceedings to only those witnesses who choose to "voluntarily" testify poses serious challenges for successful prosecution of violence against women and to victim and witness protection in Afghanistan. Even with the decree, in its current form Article 26 provides a legal shield to those accused of domestic violence who threaten relatives and intimidate them from testifying in courts.

Additionally, Afghan lawmakers hostile to women's rights will have the opportunity as soon as this month to reverse the presidential decree when parliament reconvenes, but even if parliament leaves that decree intact, bureaucratic challenges may also inadvertently victimize women. Afghanistan's system of distributing legal codes is not computerized, so courts could receive copies of the code that do not include the presidential amendment to Article 26.

The last year has been a very rough ride for women's rights in Afghanistan. Lawmakers have argued for the repeal of EVAW and tried to abolish a set-aside of seats for women on provincial councils. The courtsreversed the 10-year sentences handed down to the in-laws who brutally abused 13-year-old bride Sahar Gul in a case that had previously been seen as emblematic of the positive impact of EVAW. Female police officers, legislators and activists suffered attacks, some fatal, and threats without receiving support from the government.

Karzai undermined the credibility of the government's human rights commission by appointing unqualified new commissioners, including a former Taliban government official who urged repeal of EVAW. A committee including representatives of key government institutions prepared a draft law that would have reinstated stoning as a punishment for adultery.

It is likely that such attacks on women's rights will continue. The eagerness of Afghanistan's foreign donors to reduce their overall commitment to Afghanistan in line with the planned end-2014 withdrawal of foreign military forces is creating a space in which opponents of women's rights have freer rein to pursue their agenda. Foreign donors, who continue to provide virtually all of the Afghan government's budget, should insist that it respect and strengthen legal protections for women, not eviscerate them. Until they do, Afghanistan's hard-fought women's rights will remain perilously fragile.