Bayern looked poised for another routine win when Arturo Vidal opened the scoring in Saturday's encounter at the Allianz Arena after 17 minutes.
That prospect appeared an inevitability when Lewandowski rolled home on the rebound, but his effort was ruled out by the Video Assistant Referee, setting the tone for a chaotic end to the first half.
Hannover almost immediately won a penalty that Niclas Fullkrug netted, but was frustrated as that strike was chalked off for encroachment and the retake was saved by Sven Ulreich.
Charlison Benschop restored parity, though, marking the first goal Bayern have conceded at home since Jupp Heynckes replaced Carlo Ancelotti as coach.
A second-half Bayern onslaught looked set to go unrewarded until Kingsley Coman powered home before Lewandowski made history from the penalty spot, giving Heynckes' men added breathing room as nearest rivals RB Leipzig slumped to a 4-0 loss at Hoffenheim.
Bayern would have been ahead inside four minutes had Philipp Tschauner not produced a fine diving save to his left to turn away an effort from Vidal, who then struck the right-hand post with a low drive after Lewandowski had wastefully fired over.
Thomas Muller was played in by James Rodriguez only to be denied by Tschauner at the near post as Bayern continued in the ascendancy.
It was no surprise when the combination of Muller and Vidal led to the opener, the latter falling backwards as he met the Germany forward's far-post cross but still getting enough on the header for the ball to roll into the bottom-right corner beyond a rooted Tschauner.
Muller was instrumental again as Bayern looked to have doubled the advantage, his cross resulting in a fortunate rebound that Lewandowski tapped in. However, Bayern's celebrations turned to frustration as Lewandowski was adjudged to have strayed offside by the VAR.
Hannover then quickly broke and won a penalty as Ulreich felled Felix Klaus, though his foul did not result in a dismissal. Fullkrug converted from the spot but did so with multiple players in the box, leading to a retake that was kept out by Ulreich's low save to his right, with a few minutes to forget for the striker compounded as he struck wide on the rebound.
Muller spurned a gilt-edged opportunity to make it 2-0 before Ulreich stopped a Fullkrug volley, but the Bayern goalkeeper had no answer in the 35th minute as Benschop flicked home from Klaus' near-post corner.
Tschauner produced heroics shortly before half-time by turning Muller's close-range header against the crossbar, and Rafinha was unable to find the accuracy on a rasping low effort as Hannover somehow reached the interval level.
James appeared the most likely source of a goal after the restart, twice shooting wide and seeing an effort deflected off target.
Coman received no reward for an excellent surge down the left as Tschauner thwarted Bayern again before James skimmed the top of the crossbar. Corentin Tolisso was introduced for Javi Martinez in the 58th minute and within five minutes of his introduction he joined his team-mates in being denied by Tschauner, who diverted the France international's header over.
But Bayern's dominance finally told four minutes later, Coman controlling Muller's deflected cross superbly and rifling into the roof of the net at the far post.
Tschauner's goalkeeping exhibition continued as Lewandowski and Vidal forced him into further stops, but his valiant exertions were for nought.
Lewandowski made history three minutes from time, sending the penalty into the bottom-right corner after Martin Harnik's rash challenge on Coman.
Key Opta stats:
- Thomas Muller played his 410th competitive match for Bayern Munich, drawing level with Lothar Matthaus.
- Arturo Vidal managed to score in three Bundesliga matches in a row for the first time.
- Robert Lewandowski has netted each of his last 16 penalties in Bundesliga.
- Bayern have won their last 30 league matches versus promoted teams, scoring 99 goals and conceding only 19.