Leipzig fought back with second-half goals by Christopher Nkunku and Yussuf Poulsen before Sorloth's winning header in the 93rd minute after Gladbach had led 2-0 at half-time.
Bundesliga: RB Leipzig inch closer to Bayern Munich at top with win over Hertha Berlin; Bayer Leverkusen beat Augsburg
A superb second-half strike by defender Nordi Mukiele and a header from centre-back Willi Orban sealed the victory.
Bayern, who have a semi-final against Al-Ahly on Monday, were forced to remain at Berlin airport overnight, eventually leaving around 7 am, but this time with a stopover in Munich to change airline crew.
The win leaves Bayern 10 points clear of second-placed RB Leipzig, who have a game in hand away to crisis-hit Schalke.
European football weekend: Manchester City at Anfield, Le Classique in Ligue 1 and Mesut Ozil in Istanbul derby
What to look forward to in European football this weekend from Premier League, LaLiga, Bundesliga, Serie A and Turkey.
The pandemic has shaken football. Even one of the world's most valuable teams such as Liverpool is not immune to the impact of empty stadiums draining the business of cash.
Returning to the Bundesliga for the first time since he left boyhood club Stuttgart for Real Madrid in 2010, the veteran midfielder could make his Hertha debut against champions Bayern Munich this Friday.
Khedira arrived in Berlin on Saturday and was due to undergo a medical check on Sunday. He is under contract at Juventus until the end of the season, but head coach Andrea Pirlo has yet to play him in 2020/21.
Bundesliga: Struggling Hertha Berlin reappoint Hungarian Pal Dardai as coach in bid to avoid relegation
Dardai stood down as Hertha boss in June 2019 but replaces the sacked Bruno Labbadia with the side two points away from the relegation play-off spot after just two wins since December.
Bayern Munich’s closest challengers, RB Leipzig and Bayer Leverkusen, both lost in the Bundesliga on Saturday to give the eight-time defending champions a chance to move seven points clear at the top.
The victory was Leverkusen's first in five league games and puts them second on goal difference, level on 32 points with RB Leipzig, who host Union Berlin on Wednesday.
Bundesliga: Near-forgotten Tasmania Berlin urge 'save our record' as Schalke hit 30 matches without win
Christian Gross, Schalke's fourth head coach this season, got off to a losing start as Arsenal loanee Matteo Guendouzi, Colombia striker Jhon Cordoba and his replacement, Poland forward Krzysztof Piatek, scored for Hertha.
Hertha Berlin substitute Krzysztof Piatek scored twice for a 3-1 win over 10-man Union Berlin in their Bundesliga derby.
Moukoko broke the Bundesliga record on Saturday when he made his debut for Dortmund on the day after his 16th birthday
Bundesliga: Borussia Dortmund mum over possibility of Youssoufa Moukoko’s debut in Hertha Berlin clash
Dortmund put out a video in midweek hinting that Moukoko could feature in Berlin, but on Friday head coach Lucien Favre insisted no decision has been made.
Bundesliga had Youssoufa Moukoko in mind when it dropped the minimum age from 17 to 16 at a meeting in April. The striker could make his debut against Hertha Berlin on Saturday, making him the youngest player in league history.
Lewandowski, who played for Dortmund between 2010 and 2014, took his tally to 17 goals in 13 games against his former club. He also clocked up his 11th goal in just six Bundesliga appearances for Bayern so far this season.
Goetze, scorer of the extra-time goal that gave Germany a 1-0 victory over Argentina in Brazil in 2014, made only five Bundesliga starts at Dortmund last season.
Bundesliga: Robert Lewandowski nets four goals as Bayern Munich clinch seven-goal thriller against Hertha Berlin
The victory got Bayern back to winning ways after their record 23-match winning streak was ended by a 4-1 defeat at Hoffenheim last Sunday.
Bundesliga: Bayern Munich's Leroy Sane sidelined for two weeks after picking up knee injury, says Hansi Flick
Sane injured an anterior cruciate ligament in his right knee last season while playing for Manchester City, causing him to miss almost the entire 2019-20 campaign.