Liberty had questioned the government's order to private companies ordering them to store the communications data of all British citizens so that it could be accessed by public agencies, the Inquirer reported.
Prior to this case, Labour MP Tom Watson and Conservative MP David Davis had brought a case, in which the European Court of Justice ruled that "only the targeted retention of that data solely for the purpose of fighting serious crime" was allowed.
In its judgment, the High Court said the government's order was "incompatible with people's fundamental rights" because MPs would be able to issue data retention orders without independent review and authorisation.
The data could be Internet search histories, content of calls made or messages that have been sent. Government agencies are also able to order companies to decrypt data, making end-to-end encryption of little use in maintaining privacy.
Liberty director Martha Spurrier said: "Spying on everyone's Internet histories and email, text and phone records with no suspicion of serious criminal activity and no basic protections for our rights undermines everything that's central to our democracy and freedom – our privacy, free press, free speech, protest rights, protections for journalists' sources and whistleblowers, and legal and patient confidentiality.
"It also puts our most sensitive personal information at huge risk from criminal hackers and foreign spies.
"The Court has done what the government failed to do and protected these vital values - but today's ruling focuses on just one part of a law that is rotten to the core.
"It still lets the state hack our computers, tablets and phones, hoover up information about who we speak to, where we go, and what we look at online, and collect profiles of individual people even without any suspicion of criminality. Liberty's challenge to these powers will continue."