After New Zealand’s government began illegally spying on its own citizens, it worked to enact legislation that authorized mass surveillance by its spy agency, according to documents provided by whistleblower Edward Snowden.

The documents reveal that, during a time when the prime minister was publicly adamant that no such surveillance program existed, the government was working to harvest New Zealanders’ data and share it with foreign intelligence agencies.

An article published by the Intercept on Monday revealed details of a top secret intelligence program implemented by New Zealand’s spy agency, the Government Communications Security Bureau (GCSB), in cooperation with the U.S. National Security Agency (NSA). Documents show that the spy agency planned to wiretap a primary undersea cable link, granting it—and its Five Eyes partners, U.S., U.K., Australia, and Canada—access to the vast majority of data entering and leaving the country.

The first phase of this program, code-named “Speargun,” began in 2012 or early 2013, according to journalists Glenn Greenwald and Ryan Gallagher, who called the operation “the greatest expansion of GCSB spying activities in decades.” The second phase of the “Speargun” program, according to the Intercept, had been scheduled for “mid-2013” and involved inserting “metadata probes” into the undersea cables.

From the Intercept:

“Surveillance probes of this sort are commonly used by NSA and their partners to tap into huge flows of information from communication cables in real time, enabling them to extract the dates, times, senders, and recipients of emails, phone calls, and the like.”

Following allegations by Greenwald that New Zealanders had been subjected to domestic spying by their government, Prime Minister John Key admitted last week, for the first time, that such intelligence gathering tools were once considered. Key denied, however, ever authorizing the GCSB to engage in dragnet surveillance. In 2013 he vowed, almost a year after the agency was exposed for illegally spying on Megaupload founder Kim Dotcom, to resign if that were ever to be revealed the case.

NEW: New Zealand Spy Agency Launched Mass Surveillance Project While Publicly Denying It https://t.co/rv7xZn20F2 — Glenn Greenwald (@ggreenwald) September 15, 2014

Before last year’s surveillance bill was passed, Key claimed in a speech that it merely defined the scope of GCSB’s authority. “Much of it is alarmist,” he said of the public debate. On the day of the vote, he told parliament: “Despite ill-informed claims to the contrary, nothing in this legislation allows for wholesale spying on New Zealanders. It actually tightens, not widens, the existing regime.”

But according to the Intercept, Snowden’s documents prove that it was understood by the Key government, and the NSA, that the new law was essential to project “Speargun” and the sweeping collection of New Zealand’s private data:

“On more than one occasion, the NSA noted internally that Project Speargun, in the process of being implemented, could not and would not be completed until the new law was enacted. The NSA apparently viewed that new law as providing exactly the powers that Key repeatedly and publicly denied it would vest.”

In an op-ed for the Intercept, published concurrently with Greenwald and Gallagher’s article, Snowden spoke forcefully about the accusations he was making against Key. “Let me clear,” he wrote, “any statement that mass surveillance is not performed in New Zealand, or that the Internet communications are not comprehensively intercepted and monitored, or that this is not intentionally and actively abetted by the GCSB, is categorically false.”

Snowden admitted to having personally viewed the communications of New Zealanders as well, while working as a contractor at NSA. “The prime minister’s claim to the public, that ‘there is no and there never has been any mass surveillance’ is false,” he added.

When it came to the topic of this Saturday’s national election, Snowden was clear about what he thought the people of New Zealand should do: “The liberties of free people cannot be changed behind closed doors. It’s time to stand up. It’s time to restore our democracies. It’s time to take back our rights. And it starts with you.”

Photo via Freedom of the Press Foundation / Wikimedia Commons (CC 4.0) | Remix by Rob Price