India's Supreme Court has said women can no longer be barred from entering the Sabarimala temple, considered to be one of the holiest for Hindus.

The temple in Kerala barred women of a "menstruating age" - defined as between the ages of 10 and 50 - from entering.

Menstruating women are not allowed to participate in religious rituals or enter temples, as they are considered "unclean" in Hinduism.

The ruling came after a petition argued the custom violated gender equality.

While most Hindu temples allow women to enter as long as they are not menstruating, the Sabarimala temple is unusual in that it is one of a few temples that does not allow women in the broad age group to enter at all.

Millions of devotees visit Sabarimala every year.

In the judgment Chief Justice Dipak Misra said that "religion is for one dignity and identity", adding that "the right to practise religion is available to both men and women".

The impending retirement of Justice Misra has seen a flurry of historic liberal rulings from the court in recent days, including the striking down of colonial-era laws that criminalised adultery and gay sex.

Justice Misra, who will retire on Tuesday, was heading a five-judge bench which gave a 4-1 verdict.

The BBC's Soutik Biswas says such a stream of judgements leading up to a judge's retirement in the top court is not unusual.

"But what it also underlines is that the 25 judges of the court are some of the most overworked in the world - one study found that a single Supreme Court judge, during his tenure over four to six years, hears some 6,000 cases alone," our correspondent adds.

Indu Malhotra, the only woman judge on the bench, dissented with the majority verdict.

"Issues of deep religious sentiments should not be ordinarily interfered by the court... Notions of rationality cannot be invoked in matters of religion," she said in her dissenting opinion.

The state government of Kerala had opposed the entry of women when the case was first taken up in 2016. However it changed its stance in a recent hearing to support the petitioners instead.

At a hearing in July, petitioners argued that this custom violated equality guaranteed under India's constitution. They added that it was prejudiced against women and their right to worship.

But supporters of the ban argued that the practice had been in effect for centuries, and there was no need to change it now.

The campaign to repeal the ban on women entering the temple gathered momentum in 2016 after a protest by female students.

One of the protesters also started a #HappyToBleed campaign on Facebook against "sexist attitudes", which received support from different parts of the country.

Nikita Azad, who started the campaign, told the BBC this is a historic judgement. "It will have a large impact since the Supreme Court has destigmatised menstruation and upheld equality over religion," she said.

This is the third religious site in India where women have gained the right to enter through judicial intervention. Courts directed authorities of the Hindu temple Shani Shingapur and the Muslim Haji Ali shrine, both in the western state of Maharashtra, to allow women inside.