Hamid Karzai has been accused of trying to win votes in Afghanistan's presidential election by backing a law the UN says legalises rape within marriage and bans wives from stepping outside their homes without their husbands' permission.

The Afghan president signed the law earlier this month, despite condemnation by human rights activists and some MPs that it flouts the constitution's equal rights provisions.

The final document has not been published, but the law is believed to contain articles that rule women cannot leave the house without their husbands' permission, that they can only seek work, education or visit the doctor with their husbands' permission, and that they cannot refuse their husband sex.

A briefing document prepared by the United Nations Development Fund for Women also warns that the law grants custody of children to fathers and grandfathers only.

Senator Humaira Namati, a member of the upper house of the Afghan parliament, said the law was "worse than during the Taliban". "Anyone who spoke out was accused of being against Islam," she said.

The Afghan constitution allows for Shias, who are thought to represent about 10% of the population, to have a separate family law based on traditional Shia jurisprudence. But the constitution and various international treaties signed by Afghanistan guarantee equal rights for women.

Shinkai Zahine Karokhail, like other female parliamentarians, complained that after an initial deal the law was passed with unprecedented speed and limited debate. "They wanted to pass it almost like a secret negotiation," she said. "There were lots of things that we wanted to change, but they didn't want to discuss it because Karzai wants to please the Shia before the election."

Although the ministry of justice confirmed the bill was signed by Karzai at some point this month, there is confusion about the full contents of the final law, which human rights activists have struggled to obtain a copy of. The justice ministry said the law would not be published until various "technical problems" had been ironed out.

After seven years leading Afghanistan, Karzai is increasingly unpopular at home and abroad and the presidential election in August is expected to be extremely closely fought. A western diplomat said the law represented a "big tick in the box" for the powerful council of Shia clerics.

Leaders of the Hazara minority, which is regarded as the most important bloc of swing voters in the election, also demanded the new law.

Ustad Mohammad Akbari, an MP and the leader of a Hazara political party, said the president had supported the law in order to curry favour among the Hazaras. But he said the law actually protected women's rights.

"Men and women have equal rights under Islam but there are differences in the way men and women are created. Men are stronger and women are a little bit weaker; even in the west you do not see women working as firefighters."

Akbari said the law gave a woman the right to refuse sexual intercourse with her husband if she was unwell or had another reasonable "excuse". And he said a woman would not be obliged to remain in her house if an emergency forced her to leave without permission.

The international community has so far shied away from publicly questioning such a politically sensitive issue.

"It is going to be tricky to change because it gets us into territory of being accused of not respecting Afghan culture, which is always difficult," a western diplomat in Kabul admitted.

Soraya Sobhrang, the head of women's affairs at the Afghanistan Independent Human Rights Commission, said western silence had been "disastrous for women's rights in Afghanistan".

"What the international community has done is really shameful. If they had got more involved in the process when it was discussed in parliament we could have stopped it. Because of the election I am not sure we can change it now. It's too late for that."

But another senior western diplomat said foreign embassies would intervene when the law is finally published.

Some female politicians have taken a more pragmatic stance, saying their fight in parliament's lower house succeeded in improving the law, including raising the original proposed marriage age of girls from nine to 16 and removing completely provisions for temporary marriages.

"It's not really 100% perfect, but compared to the earlier drafts it's a huge improvement," said Shukria Barakzai, an MP. "Before this was passed family issues were decided by customary law, so this is a big improvement."

Karzai's spokesman declined to comment on the new law.