A European Union directive will require all internet service providers to retain information on email traffic, visits to web sites and telephone calls made over the internet, for 12 months.
Police and the security services will be able to access the information to combat crime and terrorism.
Hundreds of public bodies and quangos, including local councils, will also be able to access the data to investigate flytipping and other less serious crimes.
The taxpayer will reimburse internet service providers and telecoms companies for the costs associated with storing the billions of individual records.