The victory had a double bonus for Stuttgart as they are now guaranteed a Europa League place next season as final opponents Bayern have already qualified for the Champions League.
With Bundesliga champions Bayern chasing the treble, having reached the Champions League semi-final where they face Barcelona on Tuesday, Stuttgart are chasing their first silverware since 2007.
“These are moments for which you do the job,” said Stuttgart coach Bruno Labbadia. “My team fought until the last whistle, it’s unbelievable. This team has given their all for the last two-and-a-half years, it makes me really happy that they have their reward.”
In Tuesday’s other semi-final, Bayern hammered Wolfsburg 6-1 in Munich with Germany striker Mario Gomez coming off the bench to score a hat-trick in just six second-half minutes.
Labbadia admitted his team will have their work cut out to deny Bayern in the Berlin final.
“The way Bayern play is sensational, the only thing that bothers me is that even unhappy players can come in and score three goals,” he quipped.
The semi-final got off to an explosive start as Stuttgart attacked relentlessly and scored the opening goal when Ivory Coast defensive midfielder Arthur Boka fired home a Ibrahima Traore cross after only nine minutes.
Boka was then involved at the other end as he failed to stop Jan Rosenthal’s run at goal and the midfielder delicately placed his shot past Stuttgart goalkeeper Sven Ulreich to equalise for Freiburg just five minutes later.
Hosts Stuttgart then regained the lead on 29 minutes after chaos in the Freiburg defence before Austrian right-winger Martin Harnik headed home a looping cross from Christian Gentner against the underside of the bar, which proved to be the winner.
Harnik squandered a great chance to put the result beyond doubt late on, but he fired wide with time almost up and the goal at his mercy.
His miss could have proved costly as Ulreich was at full stretch to hold a save with just minutes left from Freiburg’s Czech defender Pavel Krmas to deny the guests an equaliser. There were tears at the final whistle as Freiburg were denied the first German Cup final appearance in the club’s history at the final hurdle.
Stuttgart, who are 12th in the Bundesliga, will be appearing in their sixth German Cup final, their first since losing the 2007 final, while Bayern are bidding to win the cup for the 16th time having lost 5-2 to Borussia Dortmund in Berlin last year.