Glasgow Warriors head coach Townsend, 43, previously worked with Scotland as part of Andy Robinson's backroom staff.
The former Scotland fly-half, who won 82 caps - plus two for the Lions - led Warriors to the Pro12 title in 2015.
"I am incredibly proud. It is a real honour to be given the responsibility of coaching the national team," said Townsend.
"My focus is firmly on the season ahead with Glasgow and I will be doing all I can to help the club continue to progress this year."
New Zealander Cotter, 54, has been in charge of the Scots since 2014 and led them to the World Cup quarter-finals last year.
Shortly before that tournament, the former Clermont Auvergne head coach had extended his contract until 2017.
Scotland lost all five Tests in his first Six Nations but they improved this year with wins over Italy and France, scoring a best-ever 11 tries in a single campaign.
"I believe we have moved forward by working to execute the simple things well," said Cotter, who has now coached in Europe for a decade after an eight-year spell in France with Clermont Auvergne.
"The focus has been to respect tradition but also perform in the present, be adaptive and innovative. I have been really pleased with the progress that has been made."
Media playback is not supported on this device
Scottish Rugby chief executive Mark Dodson thanked Cotter for his "considerable impact" but said the time was right to promote "one of the most sought after coaches in the game", two years out from the next World Cup in 2019.
"The time is right to take the development of the national team forward with Gregor," said Dodson.
"Gregor's playing record showed he is a man of vision and great professionalism, which he has since successfully transferred into his coaching roles.
"It is these factors which I feel will enable Scotland to continue its forward momentum, building on the strong foundations laid by Vern, with the current group of players and future Scotland internationals."
Dodson has now launched a recruitment process to find Townsend's replacement at Glasgow for next season.

Two men, aged 35 and 49, were detained for breach of the peace while a 23-year-old woman was arrested for obstructing police officers.
The incident happened at about 14:00 in Buchanan Street, while a pro-refugee rally was taking place in the same area.
A spokesman from Police Scotland: "All three people were later released."
He added: "A report will be prepared for the procurator fiscal."

North Yorkshire Chief Constable Dave Jones steps in following David Crompton's suspension after the jury concluded the 96 victims were unlawfully killed.
Mr Crompton's initial replacement, deputy Dawn Copley, stood down after her appointment was criticised.
Mrs Copley had been investigated over her conduct with another force.
As agreed with North Yorkshire's Police and Crime Commissioner Julia Mulligan, Mr Jones will remain in post until a permanent appointment is made, Ms Mulligan's South Yorkshire counterpart Dr Alan Billings said.
"I am confident that he will be able to move the force forward to a position where trust and confidence in the force can begin to be restored," said Dr Billings.
David Crompton, who was due to retire in November after four years in the post, was suspended after what Dr Billings described as "an erosion of trust and confidence in South Yorkshire Police".
Mr Crompton and the force have faced continuing criticism not only in relations to Hillsborough but also over its handling of investigations into child sexual exploitation.
Mr Jones began his career in Greater Manchester and was Assistant Chief Constable for Police Service Northern Ireland until moving to North Yorkshire in 2013.
He said he realised he was taking the post at a very difficult period and said he wanted to make a difference.
"First and foremost, I will engage with those communities both inside and outside of South Yorkshire who have been let down by the police service," Mr Jones said.
"I want to understand how their confidence in policing has been affected, and work with them to build it back up and restore pride back into the police service."
He added he would be seeking support for a full review of South Yorkshire Police.
The Deputy Chief Constable of North Yorkshire Tim Madgwick, has been named as the temporary chief of that force.
Gregor Townsend is to replace Vern Cotter as Scotland head coach in June 2017, Scottish Rugby has announced.
[NEXT_CONCEPT]
Three people have been arrested following a disturbance near a demonstration in Glasgow city centre.
[NEXT_CONCEPT]
South Yorkshire Police has appointed its second interim chief in the wake of the Hillsborough inquests.