Having previously coached in the Scotland national team set-up Gregor led Glasgow Warriors to the PRO12 semi-finals in 2012/13, his first season in charge at Glasgow, before making the PRO12 final the following year.
To acknowledge these achievements Townsend was named the GUINNESS PRO12 Coach of the Season in 2013 and 2015.
Scottish Rugby Chief Executive Mark Dodson said: "We are delighted to have retained Gregor's services up to the end of the 2017 season.
"After Glasgow Warriors became the first Scottish team in the professional era to win a major trophy it was only natural Gregor's talents would be of interest to other clubs.
"We maintain a constant dialogue with our coaches and believe he remains the right person to take the Warriors forward and consolidate their recent success.
"He has created a consistent winning culture at Scotsoun and that is benefitting both the club and the players he works with."
Gregor Townsend said: "I'm very excited to be able to continue my role with the Warriors.
"Being offered the job in 2012 was a huge honour and I've thoroughly enjoyed working with everyone at the club.
"The investment from Scottish Rugby, both in the team and facilities at Scotstoun, have played a vital role in our success and I firmly believe that there is a lot more to come from this group of players - their work ethic and desire to improve has me very optimistic about the future."
Townsend has been instrumental in developing young Scottish talent, with players like Stuart Hogg, Mark Bennett, Alex Dunbar, Peter Horne, Finn Russell, Adam Ashe, Scott Cummings and Zander Fagerson all establishing their careers at Scotstoun. This approach is best illustrated by Glasgow Warriors appointing Jonny Gray, aged 21, as club captain at the start of this season.
Glasgow Warriors had the proud distinction of providing more players to Rugby World Cup 2015 than any other club in world rugby. In total 21 players from Glasgow Warriors competed in the tournament, with 17 alone part of the Scotland squad.