Our spies monitored email and internet traffic about international diplomats vying for the job of director-general of the World Trade Organisation - a job for which National Government Trade Minister Tim Groser was competing.
The spying operation was active in 2013 and called the "WTO Project" by New Zealand's Government Communications Security Bureau (GCSB), according to a top secret document obtained by the Herald and United States news site The Intercept.
The operation involved covert surveillance of candidates from Brazil, Costa Rica, Ghana, Jordan, Indonesia, Kenya, Mexico and South Korea.
The GCSB tasking document which structured the search of internet traffic was designed to look for references to Mr Groser, the World Trade Organisation (WTO) role and his competitors, initially in any online communication but then narrowed to emails. Prime Minister John Key, who is in South Korea today with Mr Groser witnessing the signing of a Free Trade Agreement, refused to address the issue when approached for comment.
His office issued exactly the same statement released since the Herald and The Intercept began reporting internal GCSB and NSA documents relating to New Zealand.
In it, the Prime Minister's office spoke of the GCSB's contribution to national security, assured the public mass surveillance was not happening and that the agency operated legally.
"The Government will not be responding to claims made from documents stolen by Edward Snowden."
Mr Groser said last night: "We do not comment on such leaks because they are often wrong, they are deliberately timed to try and create political damage and we do not comment on any of them."
Asked if he knew the GCSB was conducting surveillance for him, he said: "I've got no comment to make whatsoever."
The documents show the WTO surveillance was carried out with the XKeyscore tool developed by the United States' National Security Agency (NSA) and used by the GCSB as part of the Five Eyes intelligence network, which includes New Zealand, Australia, Canada, the United Kingdom and the United States.
The surveillance operation was tailored to intercept electronic communications mentioning any of the candidates.
It specifically instructed the search to seek out communications with the name "Grosser" or "Groser".
The GCSB also ran a specially targeted surveillance on the candidate from Indonesia, the country's former Trade Minister Mari Pangestu.
The South Korean candidate for the WTO director-general's job - Dr Taeho Bark - was among those targeted by the GCSB.
Dr Bark, now an academic at Seoul National University and South Korea's Ambassador-at-Large for International Economy and Trade, said he had no inkling any of the countries involved would have used electronic surveillance of the sort described.
He said there was no assistance of the sort described to support his bid for the job.
"I don't have any kind of information through an intelligence organisation or bureau. It's a different world for very advanced countries."
He said he was not offended because he believed it would not have changed the outcome of his failed bid for the role.
International economic law expert Professor Meredith Kolsky Lewis, who specialises in the WTO, said she was "quite shocked" and "a little surprised" at the allegation New Zealand had spied on candidates. Professor Lewis said she could not see what advantage Mr Groser would have gained.
"The impression I got at the middle stage was that the candidates had their strong suits and weak suits you could identify without surveillance."
The GCSB's acting director Una Jagose, in response to questions about the WTO operation, said: "The GCSB exists to protect New Zealand and New Zealanders.
"We have a foreign intelligence mandate. We don't comment on speculation about matters that may or may not be operational.
"Everything we do is explicitly authorised."
Labour leader Andrew Little was horrified on being told of the operation.
"It just seems outrageous. I would have thought that a misuse of our security and intelligence agencies.
"It seems to me right outside the mandate of the GCSB. It's nothing to do with security threats."
Mr Little said it was an "unsavoury" way to campaign for an international position and it raised questions about how New Zealand had campaigned for other roles, including the UN Security Council. "That would be extremely disappointing," he said.
The Green Party co-leader Russel Norman said the revelation the GCSB was used to carry out surveillance on candidates for the WTO job would be "extremely damaging to New Zealand's reputation".
Nicky Hager is a New Zealand-based investigative journalist and an internationally recognised expert on surveillance since the publication of his book Secret Power in 1996. Ryan Gallagher is a Scottish journalist whose work at US news organisation The Intercept is focused on government surveillance, technology and civil liberties.
Read our special report here. and The Intercept story here.