Ribery helps Bayern to penalty win on return
After two second-half spot-kicks from Max Kruse had seen the game end level at 2-2 in normal-time, Gladbach appeared set for victory in the shootout when Rafinha's penalty was saved by Janis Blaswich.
However, Bayern goalkeeper Tom Starke then prevented Oscar Wendt from winning it for Lucien Favre's side, before Julian Korb smashed his effort against the crossbar.
That handed Bayern the victory and a place in Sunday's final against Wolfsburg.
Ribery had earlier fired home Bayern's second goal of the game as he made his comeback from a back injury that saw him miss his country's World Cup campaign.
The France winger provided a trademark finish after Robert Lewandowski had opened the scoring in extravagant fashion to put the Bundesliga champions firmly in command.
But the Bavarians' ill-discipline turned the game on its head either side of half-time, with Kruse's composure from 12 yards delaying Bayern's delight.
Gladbach started the 60-minute game at the Imtech Arena brightly, but they were behind in the 29th minute as Lewandowski displayed his considerable quality.
The Poland striker collected the rebound after new signing Sebastian Rode had been denied by Blaswich, jostling for the ball with two defenders before launching an audacious lob from a static position on the edge of the area over the head of the Gladbach goalkeeper.
Bayern looked to have the game wrapped up in the 34th minute when Ribery doubled the advantage in typical fashion, capping a marauding run down the left with an expertly weighted finish over Blaswich.
Yet Gladbach were handed a route back into the contest when they were awarded their first spot-kick eight minutes later, Kruse stepping up to convert after Holger Badstuber was adjudged to have handled in the area.
And further drama arrived in the final minute of normal time, Kruse converting from 12 yards again to force a shootout following Javi Martinez's barge on Andre Hahn.
Kruse's efforts proved in vain, however, as Korb failed to show similar composure in the shoot-out, with Gladbach now left to settle for a third-place play-off with hosts Hamburg.