Andrej Kramaric scored the only goal of the game as Hoffenheim handed leaders Bayern Munich only their second defeat of the Bundesliga season.
Kramaric fired home in the 21st minute to seal a win which moved the hosts to within one point of second-placed RB Leipzig and extended their unbeaten run to seven games.
Hoffenheim keeper Oliver Baumann withstood a succession of Bayern chances as Carlo Ancelotti’s men saw their own 15-match unbeaten streak brought to a close.
The home side had stated their intentions from the start, with Kramaric denied an early chance by Rafinha’s vital block in the box in the second minute.
Niklas Sule flashed a header wide in the seventh minute and Kramaric again came close with a long-range effort before 10 minutes were on the clock.
The visitors did not show up until the 13th minute when Xabi Alonso had a shot blocked in the box then Arturo Vidal flashed an effort wide of target.
Baumann saved from Vidal in the 16th minute and five minutes later Hoffenheim grabbed the lead they deserved when Kramaric fired a rising effort from outside the box.
Bayern keeper Thomas Ulreich, deputising for the injured Manuel Neuer, had to be alert to stop the hosts doubling their lead when he saved from Sebastian Rudy.
The visitors’ best chance of getting back on level terms came in first-half injury time when Robert Lewandowski hit the bar from close range after being set up by Kingsley Coman on the counter-attack.
The increasingly frustrated Lewandowski was denied by Baumann 10 minutes into the second half and the Hoffenheim keeper also did well to keep out a header from David Alaba.
As Bayern pressed for an equaliser, both Lewandowski and Alonso had shots blocked in quick success – but Kramaric almost snatched a second from a Steven Zuber through-ball.