The 35-year-old retires having scored 9515 runs at an average of 54.06 in 110 matches. He also hit 7256 ODI runs in 175 matches (fourth highest for New Zealand) and 2575 T20I runs (second highest for New Zealand) in 93 matches.
The timing of the announcement is a surprise as he walks away after one game into the three-match Test series in England, scoring 0 and 18 in the first Test defeat at Lord's, bringing an international career to an end after 16 years having made his debut in 2010.
In a statement released by New Zealand Cricket, Williamson said: "I've thought about it for a while, but over the last few days it's become clear now is the right time.
"I've always felt a strong drive and hunger for international cricket, and I take pride in knowing I've given it my all in every match I've played for New Zealand. Continuing with anything less wouldn't be right and I feel fortunate to step away on my own terms.
"I leave feeling optimistic about where this group is heading. There's a huge amount of talent, and a real desire to do something special with this New Zealand team.
"It's a team I love, and I feel incredibly fortunate to have been part of it for so long. It will continue to be dear to my heart."
The pinnacle of Williamson's career came when he captained New Zealand to victory in the inaugural World Test Championship (WTC) final against India in 2021.
He led the Black Caps in 40 Tests (22 wins, 10 losses and eight draws), 91 ODIs (46 wins, 40 losses, one tie), and 75 T20Is (39 wins, 34 losses, one tie).
New Zealand head coach Rob Walter said: "Anyone who's had the privilege of working with Kane understands he is a very special player and person.
"Although it's been short-lived, it's been a real privilege to watch him go about his work and listen to his thoughts and views on the team and the game itself.
"His numbers and batting skills speak for themselves, but it's what he means to this BLACKCAPS team, as well as world cricket - that will be his legacy. His impact on the culture and standards of this team will remain embedded in its DNA.
"Kane's always put the team first and although we're disappointed to see him go, we're happy to know he's content and at peace with his decision. An incredible player, awesome teammate, a wonderful leader and a fantastic ambassador for our sport."