In front of a 69,000 sell-out at the Allianz Arena, little Hoffenheim, who started the day with a three-point lead over their illustrious opponents, proved their lofty position was no fluke when they grabbed a 49th-minute lead.
Bosnian striker Vedad Ibisevic, the league's top scorer, hit the target to register his 18th goal in 16 matches for a team who were playing in the third division just two seasons ago.
The village side, bankrolled by multi-millionaire businessman Dietmar Hopp, had opportunities to add to their score and were made to pay when Philipp Lahm levelled for Bayern on the hour mark.
Toni then stunned Hoffenheim with his winner, scoring his eighth goal of the campaign for the defending champions.
Both sides are locked on 34 points but Hoffenheim remain top on goal difference.
"This was a close match between two fine teams," said Bayern coach Jurgen Klinsmann.
"In the circumstances, it was a superb win for us. Of all the teams we have faced in the championship, Hoffenheim are the best. We could have taken advantage of our chances earlier but we created some great opportunities in the second half."
Bayern had the better of the early exchanges with Franck Ribery providing a cross for Toni, which was too low for the Italian's head, and too quick for the fast-closing Miroslav Klose. Toni then found the side-netting after a one-two with Ze Roberto.
After weathering the early storm, Hoffenheim started to press and Ibisevic missed a good 32nd-minute opportunity with just goalkeeper Michael Rensing to beat.
But he was on target for the opener with a precise drive past Rensing in the 49th minute. Tobias Weis was then just wide with an effort three minutes later. However, Lahm came to Bayern's rescue in the 61st minute, finishing off a mazy run to beat Hoffenheim keeper Daniel Haas.
Klose and Toni came close as the game entered its final stages before the Italian supplied the killer blow in the first minute of injury time.