Australia has passed a controversial security law that will require its internet and mobile phone providers to store customer data for two years.
The government bill got Senate approval by 43 votes to 16, with the support of the opposition Labor party.
Internet providers and and mobile phone networks will now be required to store customers' metadata - the sender, recipient and time of emails and calls.
Metadata does not include the content of an email or telephone call.
The Green Party voted against the bill, along with six independent senators.
A number of amendments proposed by Green and independent senators - including an increased requirement for warrants in order to access data - were defeated by the Senate.
The government has argued that the bill is necessary to help Australia's security services fight domestic terrorism.
"By passing this Bill, the parliament has ensured that our security and law enforcement agencies will continue to have access to the information they need to do their jobs," said Attorney-General George Brandis and Communications Minister Malcolm Turnbull in a joint statement.
"No responsible government can sit by while those who protect us lose access to vital information, particularly in the current high threat environment."
But the legislation has been heavily criticised by privacy advocates, which have warned it could be open to abuse.
Greens Party senator Scott Ludlam, who voted against the bill, described the new law as "a form of mass surveillance".
"Surveillance should be targeted, proportionate and levelled at serious criminals, organised crime and national security threats," Mr Ludlam said. "This bill entrenches the opposite."
The government has not released detailed costs for the scheme, but Prime Minister Tony Abbott last month estimated that it would cost internet providers and telecommunications firms about A$400m (£210m; $315m).
Mr Turnbull, who has championed the bill, told Sky News that the government had pledged to supply a "substantial" portion of the cost.
The metadata retention rules do not extend to widely-used third-party email, video, and social media platforms such as Gmail, Hotmail, Facebook and Skype.
Also exempt from metadata retention are internal email and telephone networks, such as those provided by corporate firms and universities.
Speaking to Sky News on Wednesday, Australia's Communications Minister Malcolm Turnbull listed a wide variety of platforms and apps that are exempt, including Whatsapp, Viber, and Signal.
The gaps in services covered by the new law, and the government's advertisement of communication services that are exempt, have raised questions over the bill's potential efficacy as a counter-terror tool.
The legislation, which will come into effect in 2017, was also fiercely criticised by Australia's media industry over its potential to compromise the ability of journalists to communicate securely with sources.
The government was forced to add a Labor-sponsored amendment to the bill requiring security services to obtain a warrant before accessing journalists' metadata.
Australia is part of the "five-eyes" intelligence-sharing network, along with the US, Canada, New Zealand, and the United Kingdom.
The US already has laws under the Patriot Act allowing its National Security Agency (NSA) to collect metadata in bulk.
The NSA's data collection sparked international debate in 2013 when details of the programme were leaked by contractor Edward Snowden.