Townsend will be Warren Gatland’s attack coach while Tandy will be in charge of defence.
The inclusion of the two Scotland coaches is recognition of Townsend’s side’s performances in the recent Six Nations in which they won away against England and France in the same season for the first time since 1926.
Gatland, the Lions head coach for the third tour in a row, said it was “important to have new voices and a fresh perspective”.
He has also recruited Leinster’s Robin McBryde as his forwards coach and Wales kicking guru Neil Jenkins.
The Lions will play Japan at BT Murrayfield on Saturday June 26 before flying to South Africa for the three-Test tour against the world champion Springboks.
Scotland have been poorly represented on recent Lions tours and have not provided a player for the Test team since 2013 when Richie Gray appeared as a second-half substitute in the win over Australia in Sydney in the final Test.
Gatland has previously challenged Scotland players to show they can win important games away from home and they demonstrated that ability in Paris and Twickenham.
For Townsend, the call-up is reward for the progress he has made in his four years in the Scotland post. He toured South Africa successfully as a player in 1997, playing at stand-off in the victories in the first and second Tests which secured the series win.
“Gregor is doing an excellent job in charge of Scotland and is an outstanding coach,” said Gatland. “He also understands the challenges of touring South Africa as a player and what it takes to win there, so I am extremely happy he will be part of the set-up.
“Steve has made Scotland’s defence one of the most organised in world rugby – something we saw throughout the recent Six Nations. He’s clearly an intelligent coach and someone I am very much looking forward to working with.”
Townsend said his appointment was a huge honour.
“To be involved as a player and now as a coach is truly humbling,” he said.
“The Springboks are a formidable opponent on home turf, but looking at the talent in England, Ireland, Scotland and Wales, it is a hugely exciting opportunity for us to do something special.
“One of the great challenges of a Lions Tour is to bring together players from four different countries, in a short space of time, and create an attacking threat that will cause the opposition problems. It’s something I am already looking forward to.”
Tandy said: “To take on the world champions in their own backyard is a massive test and one I am really looking forward to being part of.
“There have been some brilliant Lions defence coaches in the past – Andy Farrell, Shaun Edwards and Phil Larder – so it’s a huge honour to be chosen.
“From a defence perspective we need to make sure we get everyone on the same page as quickly as possible.
“I am sure Gregor and I will benefit greatly from this experience and gain valuable knowledge about the Springboks ahead of the Rugby World Cup in two years’ time.”
Scotland and South Africa have been drawn in the same group at the 2023 World Cup.
The Lions will play five matches in South Africa against local sides before the first Test against the Springboks in Johannesburg on July 24.
“I am very pleased to have assembled such a high-quality coaching team,” added Gatland.
“It’s a really strong group and I’m excited to see what we can achieve together – I think we’ll all complement each other well in South Africa.”