The former fly half has been handed a major vote of confidence following his first 14 months.
Townsend took over in June last year with his remit to lead Scotland into the Rugby World Cup in the autumn of 2019, but he has now signed a new deal until 2021.
The former Glasgow Warriors head coach has won nine of his 14 matches in charge since building on Vern Cotter’s spell at the helm and finished third in his debut Six Nations campaign.
Townsend said in an interview with the Scottish Rugby Union: “It’s a huge privilege to coach the national team. It’s great I can continue that. I really enjoyed last season.
“There is a lot of work to do in the future but I am delighted I am going to be involved for another couple of years.”
Scotland are still seeking improved consistency but there have been some major results under Townsend, including two victories over Australia, Six Nations triumphs against England and France, and a 44-15 win in Argentina in their most recent game.
“It is a rollercoaster,” Townsend said. “There’s been some great highs. Being out here at the end of the game against England this year was fantastic – the atmosphere in the ground, the joy on the supporters’ faces, the players’ as well, the effort they put in, the satisfaction they got from winning.
“But also seeing the team perform well away from home in Australia in the first big game that we were in charge of, and most recently in Argentina, a terrific performance to win against a very good side.”
Two of Townsend’s assistants, Matt Taylor and Mike Blair, have also signed extended deals while Danny Wilson is set to join the coaching staff ahead of Dan McFarland’s move to Ulster, which is scheduled for January.
Townsend added: “There’s certainly a lot of improvement to be found – both from us as coaches and also our playing performances – but we’ve also seen some excellent displays over the past season, as well as a genuine desire from the players to give their best for their country.
“I’ve been really pleased with the way the squad has come together whenever we’ve been in camp. The players have built strong relationships with each other, trained with intensity and learned quickly after any setbacks we have faced.
“They have also been terrific ambassadors for their country on tours or whenever they have interacted with our supporters.”
SRU chief executive Mark Dodson hailed the development.
“I was convinced that Gregor was going to make an outstanding head coach for Scotland and we’re delighted to have secured his services for the next three years, at a very exciting time for Scottish Rugby,” Dodson said.
“It was also important to maintain the high level continuity created with the other world-class coaches within the national team set-up in Matt Taylor and Mike Blair and I’m very pleased they will continue to work alongside Gregor through to, and beyond, Rugby World Cup 2019.”