Lewandowski put Bayern ahead with a bullet header at Signal Iduna Park before Thomas Mueller doubled the visitors' lead to make it 2-0 just after the break.
Dortmund captain Marco Reus pulled a goal back when he curled a superb shot inside the post before Lewandowski settled the match.
The 32-year-old has now scored 24 goals in as many games against Dortmund, where he spent four years from 2010-2014.
Bayern have now won all of their last six matches against Dortmund.
It was a welcome victory for Bayern, who were winless in four pre-season friendlies before drawing last Friday's opening game of the new Bundesliga season 1-1 at Borussia Moenchengladbach.
Erling Braut Haaland and 16-year-old Dortmund striker Youssoufa Moukoko each had goals ruled offside either side of halftime.
Both teams wore black armbands out of respect for legendary Bayern striker Gerd Mueller, who died Sunday aged 75.
During the warm-up, the Bayern squad wore shirts with Mueller's name and number 9 on the back.
Steady rain did little to dampen the electric atmosphere as tempers quickly became frayed, with three yellow cards dished out in the first half.
Dortmund had the best early chance when England midfielder Jude Bellingham threaded a pass through the defence to Reus on 20 minutes, but Bayern goalkeeper Manuel Neuer blocked the shot with his foot.
Moukoko then had the ball in the net on 36 minutes from a Haaland pass, only to be denied by an offside flag.
Lewandowski put Bayern ahead four minutes before the break, perfectly timing his run into the box to head home a pin-point Serge Gnabry cross.
Bayern extended their advantage four minutes into the second half when Lewandowski failed to connect with an Alphonso Davies cross and Mueller swept in the loose ball.
Haaland beat Neuer three minutes later, but his effort was also chalked off.
However, Dortmund pulled a goal back when Bellingham spotted Reus in space and he unleashed an excellent strike into the corner with 26 minutes to go.
However, Lewandowski ended the tie as a contest, after Bayern capitalised on a rare mistake in the Dortmund defence.
Centre-back Manuel Akanji played a lazy pass which was snapped up and worked to Lewandowski, who slotted home, taking the wind out of Dortmund in the 74th minute.