This landmark decision follows criticism that the Aadhaar identity card reveals profile of a person’s spending habits, friends and property.
Privacy is not explicitly mentioned in the Indian constitution and the government has argued that the country's 1.25 billion people have no absolute right to it.
But the top court said the right to privacy was enshrined in the constitution, a ruling which civil liberties campaigners hailed as a milestone.
"The right of privacy is a fundamental right," the nine judges deciding the case said in a unanimous ruling.
"It is a right which protects the inner sphere of the individual from interference from both State and non-State actors and allows the individuals to make autonomous life choices."
The Supreme Court set up a special bench to rule on the issue after a legal challenge to the government's Aadhaar biometric programme, which has recorded the fingerprints and iris scans of more than one billion Indians.
The identity programme, first announced in 2009, aims to issue every Indian with a 12-digit Aadhaar number, corresponding to records that include a citizen’s fingerprints and eye scans. More than 1.13 billion Indians have been registered so far.
The government says the database, which began storing identity records in 2014, will allow it to streamline social programmes in a country where one study has estimated about 84% of every rupee paid as welfare is lost to corruption. It said in March that 490bn rupees (£6bn) had already been saved as a result of the scheme.
Prashant Bhushan, one of the lawyers working on the Aadhaar challenge, said the ruling was a blow to the right-wing government of Prime Minister Narendra Modi.
"It is a big jolt for the government because they argued that privacy is not a fundamental right," he told reporters outside the court.
Aadhaar was set up as a voluntary scheme to streamline benefit payments to millions of poor people and reduce fraud.
But in recent years it has become compulsory for a growing number of services, including opening a bank account and paying taxes.
Opponents say that its use for what are effectively essential services means their right to privacy is increasingly being violated.
Technology law expert Mishi Choudhary called the ruling a "milestone" in the global history of privacy rights.
"If I can stop smiling, then I'll be able to comment. The world's largest democracy has spoken," said Choudhary, legal director at the Software Freedom Law Center in New York.
"People who said that this (Aadhaar) is the creation of a surveillance state, they are not engaging in hyperbole.
"I personally think the mission creep of Aadhaar is very worrying. It started with one particular thing, to give an ID card to people below the poverty line, and slowly it becomes this hydra for everything... now I have a digital leash around my neck."
The government has rejected suggestions that the programme, set up in 2009, poses a threat to civil liberties, despite personal data being leaked in security breaches.
In May Attorney General Mukul Rohatgi dismissed the idea that Indians could refuse to provide their iris scans or fingerprints to the government, telling a court "the concept of absolute right over one's body was a myth".
Lawyer Bhushan said the judgement would have an impact on the Aadhaar programme but it was not yet clear how.
"Any fundamental right is subject to reasonable restrictions by law. Whether the Aadhar Act imposes unreasonable restrictions will have to be examined," he told reporters outside the court.
Legal experts had said the case would be a test of Indian democracy, with potentially far-reaching consequences if individuals were allowed to challenge laws on the basis of individual rights.
Some suggested that a ruling recognising privacy as a fundamental right could be used to overturn a controversial 2013 Supreme Court ruling which upheld a colonial-era ban on gay sex.
In an article published by the Times of India last month, Choudhary and fellow legal expert Eben Moglen argued that it would be one of the world's most important legal decisions this year.
"Societies far beyond India will be watching to see what it decides," they wrote.
"India will, as a result of the Supreme Court's judgement, take the lead among democracies in recognising and enforcing its citizens' fundamental right to privacy, or fall in line behind despotic societies in destroying it."