Erling Haaland scored twice inside the opening 10 minutes to stun Bayern before Lewandowski replied with a brace of his own in an entertaining first-half.
Leon Goretzka scored a late goal to make it 3-2 late on before Lewandowski grabbed his third in stoppage time.
Haaland broke the deadlock after 74 seconds as his deflected strike was enough to beat Manuel Neuer. The striker grabbed his second goal seven minutes later when he converted from Thorgan Hazard's cross.
Lewandowski made it 2-1 with a tap-in from Leroy Sane's cross after 26 minutes before converting from the spot just before the break when VAR decided Mahmoud Dahoud brought down Kingsley Coman inside the penalty area.
There were chances at both ends after the break but Hazard's volley hit the side-netting while Coman was denied from close-range by Dortmund goalkeeper Marwin Hitz.
Both sides also picked up injuries as Haaland was brought off on the hour mark with a knock to his ankle and Jerome Boateng was later substituted with a hamstring strain.
Bayern went ahead three minutes from time when Goretzka's volley found the back of the net before Lewandowski sealed his treble moments later.