Townsend took over from Vern Cotter in June 2017 and was handed the task of preparing Scotland for their World Cup quest in the autumn of 2019.
The former Glasgow Warriors head coach has now been handed a deal until 2021 along with coaching staff Matt Taylor and Mike Blair.
The 45-year-old said: “I have always been incredibly proud to coach Scotland and I’m delighted and grateful to be able to extend my involvement with the national team.”
Townsend has won nine of his 14 matches in charge. Scotland have beaten Australia home and away while victories over England and France helped them to a third-placed finish in the NatWest 6 Nations.
Scottish Rugby Union chief executive Mark Dodson said: “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.”
Danny Wilson is set to join Townsend’s coaching team ahead of Dan McFarland’s move to Ulster in January.