Our spies fed questions to the Central Intelligence Agency which were put to someone taken in the illegal rendition and torture programme operated by the United States' agency, a new inquiry has found.
At the time the questions were posed, the NZ Security Intelligence Service "was not aware that detainee interrogations involved torture", according to the report from the office of the Inspector-General of Intelligence and Security.
However, it was known the person being questioned - Khalid Sheikh Mohammed - "was being held by the CIA in an undisclosed location".
It later emerged in a US inquiry that he had been waterboarded 183 times.
An intelligence report from the CIA went to the NZSIS and was "seen by the Prime Minister", Helen Clark.
The details have emerged in a long-awaited report into New Zealand's knowledge and involvement in the CIA's rendition programme between 2001 and 2009.
• Spy agencies frustrate watchdog in NZSAS inquiry
• New oversight report critical of spies and highlights legal 'gap' in GCSB practices
• Spies slammed by watchdog for 'unlawful' access of database
• David Fisher: Just how bad were our spies?
The report is the first detailed examination of the role played by our intelligence agencies in the War on Terror. It found the greatest involvement was by the Government Communications Security Bureau, our electronic intelligence agency.
The report said those in charge of the agencies at the time acted with "professionalism and integrity" in a "difficult political and intelligence environment" but needed to be more aware of the risk to their agencies and New Zealand when maintaining information sharing with partners.
The report said those running the agencies were "not fully alive to the range and extent of risks for their organisations and for the Government more generally".
In relation to the CIA rendition and torture programme, the report found there was enough information in the public domain during the time under inquiry to raise questions about the lawfulness of the CIA's activities.
Instead, the agencies received and held intelligence reports from 16 of the 39 detainees found by a US inquiry to have been tortured. The reports were still held by the agencies.
While not complicit or otherwise directly connected to the CIA programme, our intelligence agencies may also have contributed information which led to those who were tortured being captured, the report stated.
"Details about the work carried out by GCSB deployees helped us to identify, for example, the particular risks linked to operations where the objective was to kill or capture enemy combatants.
"It was possible that intelligence supplied by a GCSB staff member might have resulted in, or contributed to, the capture of targets and their detention by the CIA."
The report went far wider than investigating the CIA rendition programme, digging into the contribution - and fraught difficulties - of New Zealand's intelligence efforts in the War on Terror.
It has revealed GCSB staff were involved in support of "kinetic targeting" - directing combat attacks, including missile strikes, with concern expressed in one report to Wellington over the potential impact on staff "real-time" exposure to deaths through video screens, particularly if civilians were killed.
It found NZSIS and GCSB staff "lacked adequate training and support" when deployed to Afghanistan.
Those who did go adopted a resourceful and resilient approach to compensate, yet the IGIS report revealed reservations held by staff over the legal guidance and command support they were provided.
The report found New Zealand deployed its own staff and seconded others to various international commands. The deployment resulted in different chains of command; some reported to Operation Enduring Freedom commanders, others to the International Security Assistance Force and others to New Zealand commanders.
It led to GCSB staff operating under a range of different Rules of Engagement - the legal basis on which combatants are able to take action involving the use of force. There were situations with the potential to breach human rights law but no way to verify whether this was the case, it found.
One GCSB staff member described the agency as "profoundly naïve" over the implications in deploying staff to assist on "kill or capture" missions, particularly when intelligence went to agencies not operating under standard "Rules of Engagement".
There was a lack of training and advice on "how to navigate the moral ambiguities", the person said.
There was a lack of clarity for bureau staff over the differing Rules of Engagement and the "acceptable level of collateral damage" when carrying out an attack against a high-value target.
Staff sent to Afghanistan received such conflicting reports most didn't carry personal weapons for protection, even though offered pre-deployment training, because they believe they were "strictly forbidden to carry weapons at any time".
Throughout the period, Afghanistan was an active, dangerous war zone.
The report also found a "surprising and significant gap" in government authorisations allowing the deployment of GCSB staff to Afghanistan.
While recommendations were made, the report noted much had changed since the time which was the focus of the inquiry.
Acting Inspector-General Madeleine Laracy said the agencies needed a clear mandate at ministerial level when carrying out activities with international partners "that might involve legal or reputational risk to New Zealand".
"Also, that when supporting military deployments intelligence agency staff need to be comprehensively trained to identify where human rights issues might arise."
Recommendations in the report included changes to our intelligence agencies' human rights policies which would affect information sharing with foreign partners.
GCSB director-general Andrew Hampton used release of the report to pay tribute to GCSB staff for their service to New Zealand "in often trying and dangerous circumstances".
He acknowledged recommendations to improve support, training and supervision of staff deployed abroad, but said much had changed since the period under review.
"New Zealand gains significant benefit from co-operation with international intelligence partners, especially the Five Eyes. We get access to intelligence that helps keep New Zealanders safe and secure, that we would not be able to generate by ourselves.
"All co-operation with international intelligence partners is governed by New Zealand law, including human rights obligations."
NZSIS Director-General Rebecca Kitteridge emphasised the benefit New Zealand received from its intelligence-sharing relationship with the US.
She said the new Intelligence and Security Act of 2017 specified clear legal guidelines for intelligence agency interaction with other countries.
Kitteridge said she was "pleased the Inspector-General found that no NZSIS staff had direct involvement in any unlawful conduct".
The inquiry was launched by former inspector-general Cheryl Gwyn in 2015 after the United States' Senate Committee on Intelligence published highly redacted findings on its own investigation into the Central Intelligence Agency's detention and interrogation practices.
Gwyn recently left the role of IGIS and began work as a High Court judge last month.
The US inquiry found the CIA had tortured prisoners, misled the President and the public as to its actions, and had destroyed or obscured evidence showing it had abducted people from one country for transport to another where they were tortured for information.
It also found the use of torture - or "enhanced interrogation techniques" such as waterboarding - provided no useful intelligence.
The report included - but kept secret - the names of other countries which had cooperated or participated in the CIA "extraordinary rendition" programme.
Like the US Senate report, Gwyn produced two versions - one classified and one for public release.
Those considered to be affected by the report were provided with a draft copy in June last year, meaning 14 months has passed before the public report was published.
The IGIS investigation of New Zealand's role follows inquiries in a number of countries into their own involvement.
The United Kingdom's Intelligence and Security Committee found its security agencies - specifically MI5 and MI6 - had helped pay for the renditions, provided intelligence and had allowed the renditions to take place.
Gwyn highlighted the inquiry in her office's 2017 annual report, saying the change in administration in the United States - and Donald Trump's comments supportive of torture - showed the importance of New Zealand's security agencies "to have adequate safeguards in place now to prevent possible complicity in unlawful activity" when working with other countries.
Both the NZSIS and GCSB were the focus of her inquiry, which aimed to find whether they knew of or were otherwise connected to the CIA programme.
It also sought to find what safeguards were in place at the time, and now, "to avoid the possibility of being implicated in unlawful activity of that sort".
• David Fisher is a member of a Reference Group set up by the Inspector-General of Intelligence and Security to hear views on developments possibly relevant to the work of the oversight office. The group has a one-way function in offering views to the IGIS and receives no classified or special information.