Many communities in Nepal view menstruating women as impure and in some remote areas they are forced to sleep in a hut away from home during their periods, a custom known as chhaupadi.
The new law stipulates a three-month jail sentence or a 3,000 rupee fine ($30), or both, for anyone forcing a woman to follow the custom.
"A woman during her menstruation or post-natal state should not kept in chhaupadi or treated with any kind of similar discrimination or untouchable and inhuman behaviour," reads the law, passed in an unanimous vote.
It will only come into effect in a year's time.
Chhaupadi is linked to Hinduism and considers women untouchable when they menstruate, as well as after childbirth.
They are banished from the home -- barred from touching food, religious icons, cattle and men -- and forced to sleep in basic huts known as chhau goth.
Last month a teenage girl died after being bitten by a snake while sleeping in a chhau goth.
Two other women died in late 2016 in separate incidents while also following the ritual -- one of smoke inhalation after she lit a fire for warmth, while the other death was unexplained.
Rights activists say many other deaths likely go unreported.
The Supreme Court banned chhaupadi more than a decade ago but it is still followed in parts of Nepal, particularly in remote western districts.
Lawmaker Krishna Bhakta Pokhrel, who was part of the committee that pushed through the bill, said he hoped the new law would finally see an end to the custom.
"Chhaupadi didn't end, because there was no law to punish people even after the Supreme Court outlawed the practice," Pokhrel said.
Women's rights activist Pema Lhaki described the law as unenforceable because it is related to a deeply entrenched belief system that is harder to change.
"It's a fallacy that it's men who make the woman do this. Yes, Nepal's patriarchal society plays a part but it's the women who make themselves follow chhaupadi," she told AFP.
"They need to understand the root cause, have strategic interventions and then wait a generation," she added.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)