Foreign Minister Murray McCully was mistakenly selected for a random search at Auckland Airport at the request of the United States, RNZ has learned.
Mr McCully was on his way to Washington for a meeting on combating Islamic State, and was travelling as a VIP on a diplomatic passport.
His office said he was about to board an Air New Zealand flight on 21 March when he was subjected to a random search.
The trip was one of the last official visits for the long-serving foreign minister, who is not contesting the next election and steps down officially from the role next week.
Mr McCully's office and the Aviation Security Service - the official provider of aviation security in New Zealand - described it as a local administrative error.
The Aviation Security Service said in a statement the search was a requirement of the US government and was carried out by Auckland firm Secureflight. The company's director, Peter Pilley, declined to be interviewed.
In its statement, the service said the screening was a requirement of the US government, and the names of "selectee search" passengers were advised from the US to all airlines flying direct to US ports. Passengers were asked to step aside into a different screening lane.
The US Embassy said it had protocols to ensure senior government officials travelling on official business on commercial flights were not unnecessarily subjected to secondary screening and in this case the search took place in error.
It confirmed the minister was not selected for any secondary screening in the United States.
Prime Minister Bill English said Mr McCully might have been surprised by the check.
"There's a set of protocols around people on diplomatic passports and we just want to make sure they follow those protocols.
"If there's any misunderstanding we can clear it up, but I'm sure there wasn't any negative intent involved.
"It was probably just a mistake."
Mr English said random checks were part of border control and ministers should not be worried if they were being searched.