Bayern, who also won the Bundesliga for a record fourth consecutive time this season, kept their cool in the shootout after a goalless 120 minutes with Douglas Costa beating keeper Roman Buerki with Bayern's last penalty after two Dortmund players had missed.
It was Bayern's 18th Cup victory while Dortmund have now failed in the final for the third straight year.
“It was intense,” said Bayern forward Thomas Mueller. “You could see it was a long season, the game drained all our powers. Penalties are horrible but my opinion is that Bayern deserved to win.”
Guardiola, who has won three league titles and two German Cups in his three seasons in charge, hugged and kissed his players, with tears streaming down his face after his final match in charge before joining Manchester City next season.
It was also a farewell for Dortmund captain Mats Hummels, who will leave the club to join Bayern next season, having now lost his third successive German Cup final.
The encounter between Germany's top two sides lived up to its hype in terms of intensity in the first half but chances were few and far between.
A drilled header that sailed narrowly wide from Mueller was Bayern's best chance while Dortmund had to wait 42 minutes for their first shot on target.
Bayern upped the tempo after the break, using the speed of Franck Ribery and Costa on the wings to pierce the Dortmund defence.
Thiago Alcantara and Bundesliga top scorer Robert Lewandowski twice went close.
It was Dortmund forward Pierre-Emerick Aubameyang who missed the biggest opportunity, however, when he fired over the bar in the 85th minute with only keeper Manuel Neuer to beat.
After players from both sides ran out of steam and struggled with cramp in extra time, the Bavarians stayed focused in the shootout.
Sven Bender and Sokratis Papastathopoulos failed to score for Dortmund and Bayern youngster Joshua Kimmich also had his penalty saved, but Brazilian Costa sealed the win with the final kick.
Original source: Bayern give Pep a fitting farewell