Bayern, who also won the Bundesliga for a record fourth straight time, 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 second Cup win after they lifted the trophy in 2015 when they also beat Dortmund while the Ruhr valley club have now lost in the final for the third straight year.
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 is amazing to end these great years here with such a game,” he told reporters. “I don’t look at titles or trophies. These are numbers. My track record is what I experience.”
The win in front of a roaring 74,000 crowd at the Olympic stadium also softened the disappointment of Bayern’s third consecutive Champions League semi-final exit under Guardiola earlier this month when they went out to Atletico Madrid.
“I had to win, win, win from the start and had the support of many great people. I am satisfied to be leaving with such a game,” the Spaniard said.
It was also a farewell for Dortmund captain Mats Hummels, who will join Bayern next season, having now lost his third successive German Cup final.
“It is obviously bitter to come that close every time and fail,” Hummels said. “We fought a good battle and we are very disappointed. For me, my time at Dortmund was unforgettable and I will miss them all.”
The encounter between Germany’s top two sides lived up to the hype in terms of the 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 opportunity 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 try 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 chance, 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 had his penalty saved, but Brazilian Costa sealed the win with the final kick.