NEW DELHI — India’s Parliament passed a bill Thursday to impose stronger penalties on men who attack women and to criminalize offenses such as stalking and voyeurism.

The bill passed quickly in the upper house of Parliament on Thursday; the debate in the lower house Tuesday was longer, lasting seven hours. President Pranab Mukherjee is expected to sign it into law quickly.

“I think this is an important moment,” said Vrinda Grover, a women’s rights advocate and lawyer.

The passage of the bill comes about three months after a New Delhi physiotherapy student was gang-raped on a bus and later died from her injuries. The assault drew widespread outrage and prompted protests across India, some of them violent, over the issue of women’s safety.

Unlimited Digital Access. $1 for 4 weeks.

Many Indians demanded that the government do more to protect women and impose harsher sentences on men who molest them. Reported rapes in India have risen in recent years, and northern India has witnessed a series of highly publicized gang rapes.

The new law is intended to deter and punish sexual offenders, including men who stalk and harass women, and to make the police and prosecutors more responsive.

The law expands the definition of rape, substantially increases the punishment for sex crimes such as gang rape, makes repeat offenders subject to the death penalty, and defines as crimes actions such as disrobing and voyeurism. It also imposes stricter punishment for police officers who fail to properly register complaints of sexual assault.

India’s democracy has often been faulted for being so unruly and its Parliament so dysfunctional that fundamental development issuesare never adequately addressed. That the rape bill passed both houses of Parliament speedily this week,is a sign that the voices of thousands of protesters had been heard, activists said.

The law includes many, though not all, of the measures suggested in January by a panel led by a former chief justice, J.S. Verma. But some critics argued that in the rush to pass the bill, some major issues were left out.

“This is a step forward, but the government could have done more homework to bring about a stronger legislation,” said Nirmala Sitharaman, of the Bharatiya Janata Party.,