The New Zealand Rugby Union had been desperately trying to keep Carter in the country and admitted they were "flexible" with the player who had been courted by a number of overseas clubs.
The 29-year-old is set to remain with the Crusaders, as well as the All Blacks, until the 2015 World Cup with the contract including an option allowing him a sabbatical.
This could mean Carter playing overseas in the off season or taking a break from the game.
Carter, in the company of NZRU chief executive, Steve Tew, and All Blacks assistant coach, Steve Hansen, confirmed his four-year commitment at a press conference in Christchurch.
He said: "It's been a pretty tough decision, one which I've been chewing over for probably the last months, and I'm really relieved and really excited about re-signing with New Zealand - it's a pretty special moment.
"I guess the underlining factor is the black jersey.
"It means a lot to me and the more I thought about potentially playing overseas and not being able to represent my country and wear that black jersey was pretty challenging."
Carter, the most capped All Blacks first five-eighths with 79 tests, said the 2015 World Cup was a temptation.
"It's the reason for signing such a long contract, but it's not what's driving me.
"Obviously we've got a big year ahead, but to know I've got that security of four years to another World Cup is good, although a lot can happen along the way."
Tew said Carter's signing was a big day for New Zealand and All Blacks rugby and would have repercussions both on and off the field for the next four years.
"We've said all along we can't compete on the numbers with international offers.
"Dan's made a sharp point for all of us in that the jersey is pretty important in his decision so our policy to retain the rule to be selected for the All Blacks you have to be here playing in our domestic competitions is pretty important.
"That's been brought home by his decision. We haven't played the numbers game, but as Dan indicated we've tried to be flexible and given him scope to make the most of that four years across a range of activities some which he might exercise and some which he might not."
Carter is grateful the NZRU have given him the opportunity to take an extended break.
"The Rugby Union has thought outside the square and come up with some good options, but whether I take the sabbatical in the contract is something I haven't thought about too much.
"I'm really happy playing my rugby in New Zealand at the moment and I'm looking to continue that for now."
He said he had given no assurances to any overseas club that he would play for them should he take a sabbatical.
Carter also revealed he hoped captain Richie McCaw would also re-sign with the NZRU.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.