The GCSB bill passed in Parliament last night with assurances from Prime Minister John Key that it would not open the door to wholesale spying on New Zealanders.
He made the clearest statement yet on metadata - logs about communication such as emails and phone calls - as opposed to content.
"There have been claims this bill offers no protection of metadata and allows for wholesale collection of metadata without a warrant," he said.
"None of that is true."
Under the bill, metadata was treated the same as the content of communication.
When the GCSB wanted to access metadata, it would be treated with the same level of seriousness and protection as if the GCSB was accessing the actual content of a communication.
After initially dismissing opposition to the bill as politically motivated and misinformed, Mr Key has been more active in recent days in defending the legislation to try to settle concerns of New Zealanders.
In the end the majority was two votes, not the one expected, because the Maori Party which opposed the bill did not have enough MPs in the precinct to cast its three votes and cast two instead.
The vote was 61 votes in favour to 59 against.
Labour leader David Shearer said revelations by former US National Security Agency contractor Edward Snowden about spying had created a global disquiet and that the GCSB bill had fuelled fear about the state's ability to pry.
He said New Zealand had lost an opportunity to be a world leader, "charting a path through these dilemmas that would act as a model for other countries".
"This is a sad day. We are here passing legislation that is ad hoc. It is Mickey Mouse. It will do nothing to reassure New Zealanders that their private lives are safe from the prying eyes of spies."
Mr Key said he had rarely seen so much misinformation and conspiracy about a subject as had been perpetrated about the bill.
"That has some citizens agitated and alarmed which I regret. But my regret about that would be nothing compared with my regret if this measure was not passed."
"This bill is being passed today because its provisions are needed today."
Mr Key set out in his speech a two-step process he would use to grant interception warrants before the GCSB could see the content of New Zealanders' communications under the cyber security function, which would usually involve the consent of the person involved.
The assistance function of the GCSB would not entail wholesale spying.
An inquiry had identified that the GCSB, New Zealand's foreign intelligence agency, had helped other domestic agencies just 88 times in the past 10 years or nine times a year - such assistance will be unequivocally lawful in the future.
"So this isn't and never will be a wholesale spying on New Zealanders," he said.
"It isn't a revolution in the way New Zealand conducts its intelligence operations ... It simply makes clear what the GCSB may and may not do."
Attorney-General Chris Finlayson made a stinging attack in his speech on some of the more prominent opponents of the bill including New Zealander of the Year, Dame Anne Salmond. Her suggestion that anyone who supported the bill should not turn up for Anzac Day had been "disgraceful".
National's Rodney MP and former security specialist in Iraq Mark Mitchell knows terrorism first hand and he shared it yesterday in Parliament.
He said that in 2006 in An Nasiriyah in Iraq, a supply convoy carrying food for coalition troops was attacked by al-Qaeda and al-Qaeda operatives took a satellite phone from a dead driver. From the time that the phone was stolen and the account was cancelled, 200 phone calls had been made all around the world - 14 of them to New Zealand.
"Why were terrorists who were attacking allies in Iraq making calls to New Zealand?" he asked. "That is why we have agencies like the SIS and GCSB, so they can find out whom and why and protect us."
He said the quickest way to invite a terrorist attack was to become complacent. For a decade he had witnessed the pain, suffering and fear that had come with terrorism.
"Some terror attacks are planned sitting on a dirt floor in a shanty town in Mogadishu and other times is a penthouse suite in a European city. But one thing they have in common is the desire to defeat security measures Government put in place to protect their people.
"They can sniff weakness and complacency out at 1000 miles."
Attorney-General Chris Finlayson attacks critics
On Rodney Harrison, QC
"It's not true that we haven't allowed for enough time to craft good legislation but maybe we haven't allowed enough time for the rate at which Dr Harrison can get to grips with this legislation."
On Sir Bruce Ferguson, former GCSB director
"Let us not forget that despite his recent attempts to reinvent himself as a political commentator, many of the problems we are dealing with today in this legislation occurred on his watch."
On Sir Geoffrey Palmer, former Labour PM
"[He] allowed the GCSB to operate with no legislation at all when he was Prime Minister. Sir Geoffrey has claimed this legislation is rushed. Well it isn't ... If we want to talk about rushing something let us look at the debate on the SOE bill in 1986 ... He has managed to recast himself as the guardian angel of constitutional propriety. He's not. He's deeply partisan."
On Dame Anne Salmond
"The worst contribution has come from Dame Anne Salmond ... some of her shrill and unprofessional comments ... [have comparisons with] McCarthyism and comparisons with Nazi Germany."
GCSB will be able to legally spy on Kiwis when helping three other agencies (SIS, Police, Defence), when it did so previously under highly dubious legal authority.
GCSB's functions in protecting cyber security is expanded beyond Govt communications to the private sector. It has the legal power to spy on New Zealanders under this function.
The grounds on which New Zealanders' communications intercepted incidentally (eg when spying on a foreigner speaking to Kiwis) can be kept and used has been widened.
The description of what material can be intercepted from what by a warrant has been widened to include "classes of persons", and "information infrastructures".
Any surveillance on Kiwis will require a warrant signed by the Prime Minister and Commissioner of Security Warrants.
Metadata will be treated as communication and the GCSB must obtain a warrant to access any New Zealander's metadata.
Content of Kiwis' communication will not usually be intercepted under cyber security without the consent of the person [policy not in the law].
GCSB must declare each year how many warrants it obtained against New Zealanders under which functions.
Review of GCSB and SIS in 2015 and every five years after that.