Lewandowki, voted European footballer of the year on Friday, scored twice to put Bayern 2-0 up early in the second half only for Hertha to score three times to make it 3-3 with time almost up.
However, the Poland hot-shot then converted a 93rd-minute spot kick to seal the win which lifts Bayern to fourth in the table.
The victory got Bayern back to winning ways after their record 23-match winning streak was ended by a 4-1 defeat at Hoffenheim last Sunday.
Yet the European champions again looked jaded at the Allianz Arena while Hertha finished the stronger.
Fresh from their 3-2 victory over Borussia Dortmund on Wednesday in the German Super Cup, Bayern gave a first start to US junior international Chris Richards, 20, at right-back.
In the build-up, Bayern announced the signing of defensive midfielder Marc Roca from Espanyol to replace Thiago Alcantara who has joined Liverpool.
– Hertha fight back –
Bayern made a nervy start as Hertha’s Colombia striker Jhon Cordoba beat Manuel Neuer on 15 minutes with a fierce strike, but he was offside.
Thomas Mueller headed the ball in the Hertha net on 36 minutes, but the VAR ruled he was offside.
Lewandowski first struck on 40 minutes when he fired home the rebound after Hertha goalkeeper Alexander Schwolow had saved his initial header.
It was Lewandowski’s 100th Bundesliga goal for Bayern at Munich’s Allianz Arena.
It was 1-0 at the break, but the Poland star doubled his tally six minutes into the second half when he turned through 180 degrees to fire home after Richard’s pass.
Hertha pulled a goal back when Cordoba struck with a header on 59 minutes from a free-kick by Matheus Cunha, who has been called up by Brazi.
The 21-year-old Cunha then made it 2-2 after dribbling past Jerome Boateng, then beat David Alaba and Benjamin Pavard before firing past Neuer on 71 minutes.
Bayern again pulled ahead when Mueller met Alaba’s free-kick and served up a tap-in for Lewandowski on 85 minutes.
There was still time for Hertha replacement Jessic Ngankam to header an equaliser past Neuer on 88 minutes.
However, Lewandowski netted the decisive spot kick just before the whistle after being pulled down by Berlin defender Maximilian Mittelstaedt.
– Augsburg miss top spot –
Earlier, second-placed Augsburg missed the chance to top the table as they were held to a goalless draw at Wolfsburg, who had a first-half goal disallowed.
Having beaten Union Berlin and shocked Borussia Dortmund in their opening German league games, a third straight win would have sent Augsburg top ahead of RB Leipzig, who routed bottom side Schalke 4-0 on Saturday.
With coach Heiko Herrlich missing on the sidelines due to a lung problem, Augsburg’s attack failed to find the net at Wolfsburg, who have drawn their opening three league games.
The hosts had a first-half goal by midfielder Josip Brekalo ruled out as the VAR spotted striker Wout Weghorst offside in the build up.