The French parliament has approved a controversial law strengthening the intelligence services, with the aim of preventing Islamist attacks.
The law on intelligence-gathering, adopted by 438 votes to 86, was drafted after three days of attacks in Paris in January, in which 17 people died.
The Socialist government says the law is needed to take account of changes in communications technology.
But critics say it is a dangerous extension of mass surveillance.
They argue that it gives too much power to the state and threatens the independence of the digital economy.
Main provisions of the new law:
- Define the purposes for which secret intelligence-gathering may be used
- Set up a supervisory body, the National Commission for Control of Intelligence Techniques (CNCTR), with wider rules of operation
- Authorise new methods, such as the bulk collection of metadata via internet providers
The government says it wants to bring modern surveillance techniques within the law rather than outside any system of control.
A new watchdog will oversee the intelligence services, which will have broader powers to look at classified material and handle complaints from the public.
But none of this has satisfied the critics, who range from civil liberties groups to major internet providers.
Their main worry is the way French intelligence agencies will be able to collect massive amounts of metadata from the internet - the detail of communications such as times and places rather than content.
Critics say this amounts to a mass intrusion of privacy, which in the hands of an unscrupulous government could have worrying consequences.
Apart from some dissident voices, both the governing Socialists and opposition centre-right were in favour.
One online advocacy group, La Quadrature du Net, wrote after the vote: "Representatives of the French people have given the Prime Minister the power to undertake massive and limitless surveillance of the population.
"By doing so, they're ensuring that the power of the state and the basis of our democratic system are getting ever more distant from one another."
Analysis by Hugh Schofield, BBC, Paris
It has been an unusual debate. Many in the Socialist Party who would normally have spoken out against the new powers have instead kept quiet. In the wake of the January attacks, there is little political mileage in raising doubts about the intelligence services.
Meanwhile on the right, with its clearer law-and-order tradition, most MPs support the Socialist bill. But some are opposed on points of principle. Irony of ironies, some of the harshest criticism has come from the Front National.
The consensus means that the powerful civil liberties arguments have had little of an airing in the National Assembly. In some sessions there were no more than a handful of deputies in attendance.
But the opposition from outside the chamber has been vocal. Not necessarily from the public at large (who by and large sympathise with the government's argument) but from rights groups, the press, and Internet companies.