Australian spies will soon have the power to monitor the entire Australian internet with just one warrant, and journalists and whistleblowers will face up to 10 years' jail for disclosing classified information.
The government's first tranche of tougher anti-terrorism bills, which will beef up the powers of the domestic spy agency ASIO, passed the Senate by 44 votes to 12 on Thursday night with bipartisan support from Labor.
The bill, the National Security Legislation Amendment Bill (No. 1) 2014 - (full PDF format) - will now be sent to the House of Representatives, where passage is all but guaranteed on Tuesday at the earliest.
Anyone - including journalists, whistleblowers and bloggers - who "recklessly" discloses,
"information... [that] relates to a special intelligence operation" faces up to 10 years' jail.
Any operation can be declared "special" by an authorized ASIO officer.
This also gives ASIO immunity for criminal and civil liability in certain circumstances.
Many, including lawyers and academics, have said they fear the agency will abuse this power. Those who identify ASIO agents could also face a decade in prison under the new bill, a tenfold increase on the existing maximum penalty.
The new bill also allows ASIO to seek just one warrant to access a limitless number of computers on a computer network when attempting to monitor a target, which lawyers, rights groups, academics and Australian media organizations have condemned.
They said this would effectively allow the entire internet to be monitored, as it is a "network of networks" and the bill does not specifically define what a computer network is.
ASIO will also be able to copy, delete, or modify the data held on any of the computers it has a warrant to monitor.
The bill also allows ASIO to disrupt target computers, and use innocent third-party computers not targeted in order to access a target computer. Professor George Williams of the University of NSW has warned previously the bill was too broad.
And, unlike the government's controversial plans to get internet providers to store metadata for up to two years, the bill passed on Thursday allows for the content of communications to be stored.
Most groups that had complained about the new bill also said they feared its disclosure offences went too far, with the Australian Lawyers Alliance saying they would have "not just a chilling effect but a freezing effect" on national security reporting.
Attorney-General George Brandis did not seek to allay their concerns on Thursday but said that, in a "newly dangerous age", it was vital that those protecting Australia were equipped with the powers and capabilities they needed.
When the bill passed on Thursday night, he said it was the most important reform for Australia's intelligence agencies since the late 1970s.
On Wednesday afternoon, Senator Brandis confirmed that, under the legislation, ASIO would be able to use just one warrant to access numerous devices on a network.
The warrant would be issued by the director-general of ASIO or his deputy.
"There is no arbitrary or artificial limit on the number of devices," Senator Brandis told the Senate.
However, Senator Brandis did say on Thursday that the new bills did not target journalists specifically, despite concerns from media organizations that they would be targets.
The new legislation instead targeted those who leaked classified information, such as the former US National Security Agency contractor Edward Snowden, Senator Brandis said.
"These provisions have nothing to do with the press."
Despite this, Senator Brandis refused to say whether reporting on cases similar to Australia's foreign spy agency ASIS allegedly bugging East Timor's cabinet and the Australian Signals Directorate tapping the Indonesian president and his wife's mobile phone would result in journalists or whistleblowers being jailed.
The Australian Greens, through Senator Scott Ludlam, put forward an amendment that would limit the number of computers ASIO could access with one warrant to 20 but it failed to gain support from Labor or the government.
Speaking after the bill passed, Senator Ludlam told Fairfax Media he was disappointed.
"What we've seen [tonight] is, I think, a scary, disproportionate and unnecessary expansion of coercive surveillance powers that will not make anybody any safer but that affect freedoms that have been quite hard fought for and hard won over a period of decades," Senator Ludlam said.
"I have very grave concerns about the direction that the Australian government seems to be suddenly taking the country."
Independent Senator Nick Xenophon and Liberal Democratic Senator David Leyonhjelm also put forward amendments that would protect whistleblowers but these did not gain enough support either.
The legislation, which also covers a number of other issues, addresses many of the recommendations of a joint parliamentary inquiry into Australia's national security laws.
After concerns were raised by Labor and Senator Leyonhjelm, the government agreed to amend the legislation to specifically rule out ASIO using torture.
"ASIO cannot, does not and has never engaged in torture," Senator Brandis said.
The Palmer United Party was also successful in amending the law so anyone who exposes an undercover ASIO operative could face up to 10 years behind bars instead of one.
"The internet poses one of the greatest threats to our existence," Palmer United Party Senator Glen Lazarus said, speaking out against Senator Ludlam's amendment.
The Australian Greens voted against the bill, slamming the new measures as extreme and a "relentless expansion of powers" of the surveillance state.
Senator Leyonhjelm and Senator Xenophon also opposed the legislation, as did independent Senator John Madigan.
One of the amendments put forward by Senator Xenophon would have required ASIO's watchdog, the Inspector-General of Intelligence and Security, to report publicly each year on how many devices ASIO accessed.
But Labor and the government voted against it, with Senator Brandis saying it "would not be appropriate" to report figures as it would reveal information about ASIO's capabilities.
The legal changes come amid growing concern over Islamic State extremists in the Middle East and terrorism threats at home.
Islamic State (also known as ISIL) has ordered followers to target civilian Australians. In less than a week, police in two states launched the biggest counter-terrorism raids in Australia's history, and shot dead a known terrorist suspect after he stabbed two officers in Melbourne.
A second anti-terrorism bill targeting foreign fighters was introduced in the Senate on Wednesday and will be debated next month.
These changes have opposition support and would make it a criminal office to travel to a terrorist hot-spot without a reasonable excuse.
A third bill enabling the collection of internet and phone metadata for a period of up to two years for warrantless access by law-enforcement and spy agencies will be introduced later this year.