The ex-Northampton, Brive, Castres, Montpellier, Borders and Natal Sharks playmaker was famed for his attacking prowess and started both victorious Tests for the Lions against the Springboks when Britain and Ireland's elite toured South Africa 12 years ago.
"Our first match is against Fiji at Murrayfield on Saturday 14 November and I can't wait to assist the team in their preparations," said Townsend, who won 82 caps for Scotland between 1993 and 2003 and scored a try in every game in their 1999 Five Nations triumph.
"I am delighted and honoured to take up the position as attack coach for Scotland. I have been working closely with Andy Robinson over the last few months and am relishing the opportunity to work with him and the rest of the team.
"As a player I was passionate about representing my country and as a coach I am focussed on doing everything I can to help Andy and the team to achieve success.
"I have been working at the Winning Scotland Foundation for the past two years and I have certainly learned an awful lot about preparing individuals and teams in achieving their potential and, thanks to the Foundation, I am confident I can bring these skills to the Scotland team."
Scotland face Fiji, Australia and Argentina on November 14, 21 and 28 respectively as Robinson and Townsend look to improve on their current position of 10th in the IRB World Rankings.