Wagner fought back tears as he told reporters he had decided to call time on a 64-Test career after New Zealand Cricket said he would not be in the side for Thursday's match in Wellington.
"It's never an easy time to do something like this, but the time has obviously come," said the 37-year-old Wagner, who has taken 260 Test wickets.
"It's been amazing to represent the Black Caps. It's been some of the proudest moments of my life.
Fiery short-ball specialist Wagner said he would leave the squad before the start of next week's second Test in Christchurch.
"I'm looking forward to one final week in camp and will be doing everything I can to help prepare and support the boys," he said.
Wagner cited last year's one-run victory over England in Wellington, where he took the last wicket to draw the series, as among his career highlights along with winning the inaugural World Test Championship in 2021.
"I've enjoyed every single moment of playing test cricket for the Black Caps and am proud of everything we've been able to achieve as a team," he said.
Wagner made his New Zealand debut in 2012 after arriving from his native South Africa four years earlier.
"To the New Zealand public and the fans, I can't thank you enough, for your support, for making me feel welcome, for making me feel like a Kiwi," said Wagner.
Only Richard Hadlee, current captain Tim Southee, Daniel Vettori and Trent Boult have taken more Test wickets for New Zealand than Wagner.
New Zealand head coach Gary Stead said on Tuesday that Wagner was "one of the greats".
"He has been through an incredible era and been a huge cog of the bowling attack over the years.
"We'll remember his lion-heartedness, the way he just kept finding a way to make something happen."