It said religion is a way of life basically to link life with divinity.
While Justices R F Nariman and D Y Chandrachud concurred with the CJI and Justice A M Khanwilkar, Justice Indu Malhotra gave a dissenting verdict.
The court pronounced its verdict on a clutch of pleas challenging the ban on entry of women of menstrual age in Kerala's Sabarimala temple and said law and society are tasked with the task to act as levellers.
The bench passed four sets of separate judgements.
The CJI said devotion cannot be subjected to discrimination and patriarchal notion cannot be allowed to trump equality in devotion.
He said the devotees of Lord Ayyappa do not constitute a separate denomination.