Robert Lewandowski scored four goals, including a 93rd-minute penalty, to rescue Bayern Munich a 4-3 victory over Hertha Berlin in a dramatic Bundesliga clash at the Allianz Arena.
The German and European champions' 32-game unbeaten streak was ended in a shock 4-1 loss at Hoffenheim last weekend and they nearly dropped two more points on Sunday.
Lewandowski had put Bayern two goals in front - the second assisted by full debutant Chris Richards - but Jhon Cordoba powered in a header with almost an hour played and Matheus Cunha scored an impressive equaliser soon after.
The prolific striker's hat-trick goal was then instantly cancelled out by Jessic Ngankam in an incredible second half, but Lewandowski won a penalty in stoppage time that he stepped up to convert as Bayern got back to winning ways in the league.
Hertha thought they had the lead inside 15 minutes, only for Cordoba's thumping strike to be ruled out for offside.
Bayern had an offside goal of their own chalked off by VAR when Thomas Muller headed in from close range, though they were in front four minutes later via Lewandowski.
Alexander Schwolow parried Lewandowski's initial header but the ball was sent back to the edge of the six-yard box and the striker volleyed in.
Lewandowski's landmark 100th Bundesliga goal at the Allianz Arena arrived five minutes into the second half as he collected Richards' pass inside the box, worked a bit of space and arrowed a shot into the bottom-left corner.
But Cordoba headed in Cunha's free-kick to pull one back, before the latter exchanged passes with substitute Krzysztof Piatek to coolly tuck past Manuel Neuer and equalise.
Bayern, who beat Borussia Dortmund 3-2 to win the DFL-Supercup in midweek, temporarily restored their lead thanks to Lewandowski's tap-in after Muller helped on a free-kick with 85 minutes on the clock.
The visitors levelled once again two minutes from time - Ngankam, on the field for 64 seconds, stooping in to head past Neuer.
But there was still time for one last twist as Lewandowski was dragged down in the box and stepped up to win the match for Hansi Flick's men.
What does it mean? Normal service resumed for Bayern - just!
Bayern had won 23 games in a row in all competitions prior to last week's shock loss to Hoffenheim.
They showed signs of a hangover here, and Flick will not be pleased with his side's defending, but they have at least picked up back-to-back wins following that DFL-Supercup triumph.
The champions had 67 per cent of the ball and managed an incredible 22 shots - 12 of those in the second half - as they edged a thrilling contest to go fourth place in the embryonic table.
Lewandowski the four-goal hero
Perhaps the biggest factor in Bayern's loss to Hoffenheim last week was that Lewandowski did not start - the first time in two years he had been benched for a league game.
In the week he was named UEFA Men's Player of the Year for 2019-20, he showed yet again why he is the best striker in the world with four more goals here from 13 attempts.
Neuer finally beaten
Bayern keeper Neuer had kept 15 clean sheets in 21 previous Bundesliga meetings with Hertha and needed one more to set a new record for shutouts against one opponent.
He was beaten three times here, though, and will feel he could have done better to keep out at least one of those attempts - particularly Cordoba's header, which he got a hand to.
Bayern face Duren Merzenich in their rearranged DFB-Pokal first-round tie on October 15, while Hertha's first game back after the international break is a league meeting with Stuttgart two days later.