Just a "handful" of senior cabinet ministers were aware the security services had powers to collect the phone records of British citizens in bulk, Nick Clegg has claimed.
The former deputy prime minister said he was "astonished" the extent of MI5's ability to access UK communications data had not been scrutinised in Parliament.
And he said the Investigatory Powers Bill, laid out by the Home Secretary in the Commons this week, meant previously secret powers were being "forced out into the open".
The Government has said the data-collection powers have helped security and intelligence agencies to prevent terrorist attacks.
Home Secretary Theresa May revealed on Wednesday that successive governments since around 2001 have authorised secret directions allowing agencies such as MI5 and GCHQ to collect communications data in bulk under the Telecommunications Act 1984.
The agencies used records of phone contacts - but not the content of calls - to identify "subjects of interest" in the UK and overseas.
Former Liberal Democrat leader Mr Clegg said he was told about the secret surveillance upon becoming deputy prime minister in coalition in 2010.
Writing in the Guardian, he said: "When a senior official told me that the previous government had granted MI5 direct access to records of millions of phone calls made in the UK - a capability only a handful of senior cabinet ministers knew about - I was astonished that such a powerful capability had not been declared either to the public or to Parliament and insisted they should be reviewed.
"That the existence of the previously top secret database was finally revealed to Parliament by the Home Secretary on Wednesday ... speaks volumes about how far we've come in a few years."
Mr Clegg said the combination of the revelations by US whistleblower Edward Snowden and the Liberal Democrats' challenges to the torpedoed Communications Data Bill, a precursor to the latest proposals, had "proved a potent recipe for change".
"The draft bill that was published this week was the result. It is far from perfect. Many of the powers it contains are controversial and have evolved over time without any meaningful parliamentary scrutiny," he said.
"But pause and compare this bill to every recent attempt to legislate in this area and we see evidence of a remarkable journey."
He added "democratic oversight will have been strengthened" by the new bill, which will explicitly confirm the power to access data from telecoms companies.