Internet firms will have to store details of people’s online activity for 12 months under a new surveillance law to be applied in the UK.
The government is promising strict safeguards, including a ban on councils accessing people’s internet records and a new offence of misuse of the data.
Ministers are also facing calls for judges to sign warrants to access the content of digital records.
Currently responsibility lies with Home Secretary Theresa May.
The draft bill, which David Cameron says is one of the most important pieces of legislation of this parliament, will be published in the House of Commons on Wednesday.
It will be examined in detail by both Houses of Parliament before the final bill is voted on next year.
The language in the draft bill will be dry – but quite simply it creates new powers to allow arms of the state to access your online life – if they have cause and legal justification to do so.
How will the powers be used? Most certainly against terrorism suspects, organised criminals and people involved in abuse, exploitation and kidnappings.
Will they be used against the innocent? Ministers will promise world-leading levels of restrictions, scrutiny and oversight which they say will be designed to prevent abuse from ever taking place.
Critics will call this a snooper’s charter – but security chiefs and police say they’re not interested in your online shopping habits – only the habits of serious threats to society.
And they say this legislation is long overdue – and has the backing of three major reports in the last year that broadly agreed that there should be no safe space online for criminals.
Mrs May has long called for new laws to give police and security services the power to access online communications data, saying some sites had become “safe havens” for serious criminals and terrorists.
She has argued for similar rules to those governing phone records – which can be accessed without a ministerial warrant – for online communications.
The bill is expected to propose compelling companies to hold “internet connection records” for 12 months so they can be requested by authorities.
Such data would consist of a basic domain address, and not a full browsing history of pages within that site or search terms entered.
For example, police could see that someone visited www.bbc.co.uk – but not the individual pages they viewed.
Mrs May has said the government “will not be giving powers to go through people’s browsing history”.
Councils will not be able to obtain these records, Home Office sources said.
For more intrusive surveillance – involving the detailed content of the communications – security services need to obtain a warrant.
In June, the government’s independent reviewer of terrorism, David Anderson, said the current law was “fragmented” and “obscure” and called for comprehensive new legislation to be drafted from scratch.
Opposition parties, civil liberties campaigners and some Conservative MPs have raised concerns about the government’s plans, which were briefed to cabinet ministers on Tuesday and first announced in May’s Queen’s Speech.
Among the safeguards emphasised by Home Office sources would be a new criminal offence of “knowingly or recklessly obtaining communications data from a telecommunications operator without lawful authority”, carrying a prison sentence of up to two years.
Mrs May has said the bill does not include some “contentious” parts of the 2012 plan, dubbed a “snooper’s charter” by critics.
The requirement included in the British government’s draft Investigatory Powers Bill, to be published later.