Lee scored in each half against an uncharacteristically poor Bayern, who are now just four points clear after Bayer Leverkusen's 2-0 win at Augsburg.
"We played against a team with a lot of life and spirit and who was prepared to fight for every moment. Today we weren't at our best," Kompany said.
"We'll use the defeat today to build fire into the game on Friday (at home to RB Leipzig) because that's the only way we can provide an answer."
Injuries meant Kompany was unable to call on several first team regulars including Harry Kane, Manuel Neuer, Alphonso Davies, Kingsley Coman, Serge Gnabry and Joao Palhinha.
Kane's absence was particularly telling in the first half, with the league leaders dominating possession but unable to convert any of their half chances into a goal.
Mainz boasted a better-than-expected home record against the German giants, having won three of their past four home league games over Bayern.
The home side struck shortly before half-time, Lee taking advantage of a poor clearance from his South Korea teammate Min-Jae Kim to hammer home.
Even with the knowledge that Leverkusen were ahead in Augsburg, Bayern came out poorer after half-time, lacking precision and energy.
Mainz soon capitalised through Lee again. Armindo Sieb threaded a clever cross goalwards for Lee to collect before blasting home on the spin.
Leroy Sane tapped in a deflected Joshua Kimmich shot in the 87th minute to give the league leaders hope, but Mainz held firm for a famous home win.
The result moved Mainz, who battled relegation last season, up to sixth.
Defending champions Leverkusen continued their recent resurgence, winning comfortably 2-0 at Augsburg, their seventh victory in a row.
Martin Terrier put Leverkusen in front 14 minutes in, curling the ball home with his first touch after a lovely low cross from Jeremie Frimpong.
Florian Wirtz added a second in the 40th minute when he controlled the ball, sold the Augsburg defence a dummy before skipping a shot across the grass and into the bottom corner.
'Shame on the club'
Union Berlin drew 1-1 at home against last-placed Bochum in a game suspended by around half an hour after the visiting goalkeeper was hit by an object thrown from the crowd.
Bochum, were reduced to 10 men when Koji Miyoshi was red carded 13 minutes in, took the lead through Ibrahima Sissoko despite the deficit 10 minutes later.
Union levelled things up through Benedict Hollerbach in the 33rd minute, but were unable to take advantage against their undermanned opponents.
With the game in stoppage time and Union pushing, Patrick Drewes was hit by what appeared to be a cigarette lighter, with the refree ordering the players off the pitch.
When they returned, both sides kicked the ball between themselves until the clock wound down, apparently in agreement not to attack after the incident.
Bochum striker Philipp Hofmann, who replaced Drewes between the sticks, said the incident was "a shame on an otherwise likeable club".
In Saturday's late game, goals from Derrick Koehn and Marvin Ducksch took Werder Bremen to a 2-0 win at St Pauli, taking them up to seventh in the table.
The match was interrupted by smoke from pyrotechnics for 10 minutes in the second half.
A double from Alassane Plea and goals to Robin Hack and Tim Kleindienst took Borussia Moenchengladbach to a 4-1 win over Holstein Kiel.
Gladbach have now lost just one of their past eight league games while Kiel, playing their first season in the top flight, sit second last.