Under the terms of the deal Whitelock will take a break from New Zealand rugby at the end of this year to take up a short-term contract with Japanese club Panasonic. He will miss the 2020 Super Rugby season and return to New Zealand at the end of the Japanese Top 14 season in May 2020.
The re-signing of the two-time Rugby World Cup champion adds him to a core group of players who have now committed to New Zealand Rugby.
"This is a major re-signing for us and we're absolutely delighted that Sam has chosen to sign a four-year deal, NZR chief executive Steve Tew said." He's a world-class player, an All Blacks Centurion, the most capped All Blacks lock of all time and he carries immense mana.
"His recommitment alongside a number of other key players gives us a strong foundation for the next four years. I know the news will be welcomed by fans here in New Zealand and around the world.
"We know our players have a number of choices to make when it comes to where they play their rugby and we have to be flexible when it comes to renegotiating with our leading players, and that's what we have done with Sam.
"He'll have a short break away with his young family and experience a different culture, before returning to New Zealand. We think having a short playing stint in Japan as part of a long-term, four-year commitment is a win-win for him and us."
Tew said NZR's board had also given approval for Whitelock to be selected for the All Blacks in 2020, a decision made on the basis of his long-standing and outstanding service to New Zealand Rugby and the fact he had signed a four-year deal. Whitelock also has exit clauses in his contract.
Whitelock had already been signed through to 2020 but had decided to negotiate a longer contract early.
Whitelock said he was grateful to New Zealand Rugby, the Crusaders and Canterbury Rugby for their support in making the decision.
"I'm really proud to commit to these teams for the next four years." he said. "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."
All Blacks head coach Steve Hansen said: "Sammy is a very special player, an outstanding athlete, and has been a hugely respected leader in our group for some time now.
"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."