The measures have been criticised by rights groups and set the government up for potential clashes with Internet companies who are under public pressure to ensure privacy.
But in the wake of the deadly jihadist attacks in Paris in January, and coming a day after the Tunisian museum shootings that killed 21 people including two French tourists, the government said the measures were vital for effective policing.
"There cannot be a lawless zone in the digital space," said Prime Minister Manuel Valls.
"Because we often cannot predict the threat, the services must have the power to react quickly."
The new law allows authorities to spy on the digital and mobile communications of anyone linked to a "terrorist" enquiry without prior authorisation from a judge, and forces Internet Service Providers (ISPs) and phone companies to give up data upon request.
Intelligence services will have the right to place cameras and recording devices in private dwellings and install "keylogger" devices that record every key stroke on a targeted computer.
The authorities will be able to keep recordings for a month, and metadata for five years.
Valls sought to allay fears that the law was a French version of the "Patriot Act", which the United States used to authorise blanket spying powers after the attacks there on September 11, 2001.
Procedures will be "precisely defined", any request for data will have to be "justified" and decisions to begin surveillance will be taken personally by the prime minister and will be for a limited time.
"It in no way allows a generalised surveillance of citizens," said Valls.
- 'Need more investigators' -
France is one of the last Western countries to pass comprehensive legislation governing modern surveillance -- having till now relied on a law passed in the pre-Internet days of 1991.
Louis Caprioli, former counter-terrorism head at French intelligence agency DST, said he thought the measures were "proportionate" and that the judiciary had always worked closely with the intelligence services to ensure rights are protected.
But he said surveillance alone would not be enough to meet the threat.
"We need sufficient human resources and currently they are clearly insufficient," said Caprioli.
"We've added some technicians -- that's a good thing -- but we also need many more investigators on the ground."
However, the bill has attracted criticism from lawyers, civil rights activists and industry experts.
The National Digital Council, a consultative body, took aim at the plans to sweep up huge amounts of metadata using automated systems.
"This approach has proved extremely inefficient in the United States despite astronomical costs," said Tristan Nitot, a member of the council.
The bill's presentation also coincided with criticism from Europe's top rights body over France's recent decision to block websites accused of condoning terrorism, warning that restricting liberties to fight extremism was a "serious mistake".
Despite the criticisms, polls show that the French public want to step up surveillance in the wake of the January attacks in and around Paris that shook the country and left 17 dead.
An Ipsos survey for Europe 1 radio station and Le Monde daily at the end of January showed 71 percent of people were in favour of general bugging without the need to get a warrant from a judge.