Sommer, 25, has signed a five-year contract with the Foals and joins on a free transfer when is current contract with Basel expires.
"After Marc-Andre ter Stegen informed us that he would definitely like to leave in the summer, we sat down with his new club and ironed out the transfer agreements," said Gladbach's director of sport Max Eberl.
"He will be moving abroad, that is for certain. His successor in the Borussia goal will be Yann Sommer, an excellent goalkeeper who has already gained a lot of international experience despite being only 25, and we're delighted he has chosen us."
Germany international Ter Stegen is expected to join Barcelona, with an announcement due once their current number one Victor Valdes finds himself a new club for next season.
The Foals have wasted no time in finding a suitable replacement, with Sommer bringing his experience of many years in the Champions League and Europa League for the Swiss champions.
He will be understudy to Wolfsburg's Diego Benaglio in the Switzerland goal at the World Cup this summer, after which he will join the Bundesliga side, who will be hopeful of offering him European football again next season.
They are currently just two points behind the top six, without a win yet in 2014.