Contentious data retention laws have passed Federal Parliament, with both major parties voting for the legislation in the Senate.

The laws will force telecommunications providers to keep records of phone and internet use for two years and allow security agencies to access the records.

Companies already retain the data but for varying durations and in an unregulated environment.

The Coalition and Labor have argued the laws were necessary to help authorities in counter-terrorism and serious crime investigations.

Both major parties knocked back several amendments put forward by the Greens and concerned crossbenchers during Senate deliberations.

Labor announced last week that it would vote with the Coalition after the two parties agreed to several amendments, including specific protections for the phone and internet records of journalists, in a bid to protect anonymous sources and whistleblowers.

Loading...

The Greens argued strongly against the law, saying it would entrench "passive, mass surveillance".

Senators Nick Xenophon and David Leyonhjelm had also sought to change the legislation to increase privacy protections.

But Attorney-General George Brandis said the legislation, which passed with 43 votes to 16, would strike the right balance.

"It does contain safeguards that were not there before, it is in the Government's view, shared I'm pleased to say by the Opposition, a measured and proportionate response," he said.

The cost of retaining the information is set to be partly covered by the taxpayer in what the Government described as a "significant" contribution.

There are concerns telecommunications companies will pass on the rest of the cost to consumers.