The court ruled that the controversial Section 66A of the Information Technology Act was unconstitutional.
In recent years, several people have been arrested for their comments on Facebook or Twitter, sparking outrage.
The government had defended the law, saying it was meant to deter people from uploading offensive material.
Tuesdays Order was delivered by a two-judge bench of the Supreme Court on petitions filed by civil rights groups and a law student who argued that Section 66A violated people’s fundamental right to freedom of speech and expression.
“Section 66A is unconstitutional and we have no hesitation in striking it down,” news agency AFP quoted Justice RF Nariman as saying in court.
“The public’s right to know is directly affected by section 66A,” he added.
Section 66A was sweeping in its powers – it could send a person to jail for three years for sending an email or other electronic message that “causes annoyance or inconvenience”.
The law was first challenged by a law student after two young women were arrested in November 2012 in Mumbai for comments on Facebook following the death of politician Bal Thackeray.
Shaheen Dhada was held for criticising Mumbai’s shutdown after Thackeray’s death. Renu Srinivasan, who “liked” the comment, was also arrested. The two were later released on bail.
The arrests led to outrage in India with many calling for the law to be scrapped.
Since then there have been several other arrests under the law, leading to charges of abuse:
On 17 March 2015, a teenage student was jailed in the northern state of Uttar Pradesh for allegedly posting a comment on Facebook criticising state minister Azam Khan. The teenager was later freed on bail.
In October 2012, a 46-year-old businessman in the southern city of Pondicherry was arrested for a tweet criticising Karti Chidambaram, son of then finance minister P Chidambaram. He was later released on bail.
In September 2012, there was outrage when a cartoonist was jailed in Mumbai on charges of sedition for his anti-corruption drawings. The charges were later dropped.
In April 2012, the West Bengal government arrested a teacher who had emailed to friends a cartoon that was critical of Chief Minister Mamata Banerjee. He too was later released on bail.
Within minutes of Tuesday’s court order, #Sec66A was trending on Twitter with many Indians applauding the ruling.
Delhi’s governing Aam Aadmi Party welcomed the order: