Bayern made two changes, as Thomas Muller and Kingsley Coman returned while Dortmund made four alterations, with Thorgan Hazard, Thomas Meunier, Nico Schulz and Dan-Axel Zagadou all recalled.
Erling Haaland gave the visitors a perfect start after giving them the lead in the second minute with a deflected shot from the edge of the box after an offload from Thomas Delaney.
Haaland quickly made it 2-0 for BVB in the ninth minute and got his brace with a close range finish after a good attacking play led to Hazard playing a cut-back in a dangerous area.
Robert Lewandowski pulled a goal back for the Bavarians in the 26th minute with a tap-in after Leroy Sane did all the work to beat his marker on the left wing and played a square pass.
Bayern were awarded a spot-kick just before the break after Mahmoud Dahoud brought down Coman inside the box with the help of the Video Assistant Referee (VAR) monitor and Lewandowski planted his strike into the bottom corner to equalise for the hosts.
Lewandowski had a chance to make it 3-2 for Hans-Dieter Flick's charges in the 63rd minute after receiving an offload from Sane on the edge of the box but he blazed his effort over the bar.
However, Leon Goretzka completed the comeback or the hosts in the last two minutes with a low strike inside the box after pouncing on a rebound.
Lewandowski sealed the three points for Flick's troops and completed his hat-trick in the last minute with a strike across goal into the bottom corner to send the Bavarians top of the log.