Robert Lewandowski scored twice off the bench to send 10-man Bayern Munich into the German Cup semi-finals as his late penalty secured a 5-4 home win against second division Heidenheim on Wednesday.
Lewandowski came on for the second half and netted the winning penalty six minutes from fulltime for 18-times cup winners Bayern, who had Niklas Suele sent off after 15 minutes.
"I don't know how to rate this game," said Bayern midfielder Thomas Mueller.
"That they came back to 4-4 after we led 4-2, so that cannot please us. The match should have gone differently after we went 1-0 up."
The Bundesliga champions took the lead through Leon Goretzka's 12th-minute opener, but goals from Robert Glatzel and Marc Schnatterer put the visitors ahead.
Thomas Mueller equalised eight minutes into the second half, before Lewandowski and Serge Gnabry gave the home side a two-goal cushion.
Yet Heidenheim did not give up and Glatzel netted twice more, including a penalty, in the space of four minutes to level.
A handball in the area earned Bayern a penalty that Lewandowski coolly converted, sending them through to the last four along with Hamburg SV, RB Leipzig and Werder Bremen, who claimed a 2-0 win at Schalke 04 thanks to second-half goals by Milot Rashica and Davy Klaassen.
Bremen had midfielder Nuri Sahin sent off for a second bookable offence in the last minute.