The Crusaders lock has won 108 caps for the All Blacks and will be out to help New Zealand triumph at the World Cup at this year's showpiece in Japan.
Whitelock will miss the Super Rugby season to play for Panasonic on a short-term deal, before returning to New Zealand at the end of the Japanese Top League season that May.
"Sammy is a very special player, an outstanding athlete, and has been a hugely respected leader in our group for some time now," New Zealand coach Steve Hansen said.
"Together with Brodie Retallick, he has been part of what we consider one of the world's best locking combinations, but he is very much a world-class player in his own right. He's a deep thinker on the game, cares passionately about the All Blacks and has done incredibly well in the handful of Tests which he has captained so far.
"Knowing that he has recommitted for four more years is huge for the All Blacks, the Crusaders and New Zealand Rugby. We're all incredibly proud of what he has achieved so far in the jersey and look forward to the next four years."
Whitelock said: "I'm grateful to New Zealand Rugby, the Crusaders and Canterbury Rugby for their support of myself and my family in making this decision, and I'm really proud to commit to these teams for the next four years.
"Ultimately, this decision allows me to take some time with my family to experience a new rugby environment in Japan, before coming back refreshed and ready for the remainder of 2020 and beyond.
"I'm pleased there is clarity around my playing future, so I can focus on the remainder of this 2019 season with the Crusaders."