Hertha scored through Vedad Ibisevic with the Bosnian volleying in for his ninth goal and his first since November, with Bayern, who crushed Arsenal 5-1 in the Champions League in midweek, lacking any game plan despite controlling possession.
The Bavarians, who looked a shadow of the team that obliterated Arsenal with three goals in 10 minutes, had few clear-cut chances in the second half.
But Lewandowski was in the right place at the right time to fire in from close range for his 16th league goal in the sixth minute of stoppage time after Arjen Robben had seen his shot blocked.
Bayern, who have now won just one of their last three league games, moved up to 50 points with RB Leipzig, in second place on 42, travelling to Borussia Moenchengladbach on Sunday.
Borussia Dortmund rebounded from their midweek Champions League loss at Benfica to ease past VfL Wolfsburg 3-0 and climb into third place on 37 points.
Borussia Dortmund's Andre Schuerrle in action with VFL Wolfsburg's Ricardo Rodriguez
REUTERS An own goal from Jeffrey Bruma put them in the driving seat before Lukasz Piszczek and Ousmane Dembele increased their lead with second-half goals.
Hoffenheim joined them on 37 points after their 2-0 victory over bottom side Darmstadt 98, courtesy of Andrej Kramaric's brace.
Eintracht Frankfurt squandered their chance to go third in the standings, slumping to a 2-0 defeat by visitors Ingolstadt to drop to fifth on 35 points.
Struggling Hamburg SV's Aaron Hunt went from hero to villain after putting them ahead before missing an 86th-minute penalty in their entertaining 2-2 draw against Freiburg.
Hamburg failed to make it three wins in a row but the point was enough to keep them just above the relegation zone.
RESULTS:Hamburg SV 2 Hunt 15, Gregoritsch 57
Freiburg 2 Philipp 23, Vincenzo Grifo 72
Hertha Berlin 1 Ibisevic 21
Bayern Munich 1 Lewandowski 90+6
Eintracht Frankfurt 0 FC Ingolstadt 04 2 Bregerie 26, Pascal Gross 69(pen)
Borussia Dortmund 3 Jeffrey Bruma 20(og), Piszczek 48, Dembele 59
VfL Wolfsburg 0Hoffenheim 2 Kramaric 64,90+3(pen)
SV Darmstadt 98 0Mainz 0 Werder Bremen 2 Serge Gnabry 16, Thomas Delaney 23
Standings P W D L F A
Pts1
Bayern Munich 21 15 5 1 46 13
502
RB Leipzig 20 13 3 4 36 20
423
Borussia Dortmund 21 10 7 4 43 23
374
Hoffenheim 21 9 10 2 38 21
375
Eintracht Frankfurt 21 10 5 6 25 20
356
Hertha Berlin 21 10 4 7 28 24
347
Cologne 20 8 8 4 29 18
328
Bayer Leverkusen 21 9 3 9 34 30
309
Freiburg 21 9 3 9 28 36
3010
Borussia Moenchengladbach 20 7 5 8 22 27
26