Bundesliga: Hoffenheim 1 Bayern Munich 2
In avoiding defeat, Pep Guardiola's side stretched their unbeaten league run to 36 matches, equalling the record set by Hamburg between January 1982 and January 1983.
Niklas Sule gave the hosts the lead in the 34rd minute following a mistake from Manuel Neuer.
However, Bayern equalised in fortuitous fashion five minutes later when Franck Ribery's free-kick was deflected in by Mario Mandzukic for his eighth league goal of the season and Thomas Muller netted the winner 15 minutes from time.
The victory meant Bayern climbed back to the top of the table and set a new club record for their longest unbeaten start to a Bundesliga season, surpassing the old mark of 10 matches set at the start of the 1968-69 campaign.
Hoffenheim made one change from last week's win at Hannover, Kevin Volland replacing Eugen Polanski, while Dante and Javi Martinez returned for Bayern after respective ankle and groin injuries.
After a quiet opening to proceedings, Philipp Lahm and Muller were both denied by Hoffenheim goalkeeper Koen Casteels within the space of two minutes.
Lahm was kept out at the near post from the tightest of angles in the 15th minute before the Belgian flung himself to his left to parry Muller's powerful drive from the edge of the area.
The visitors began to dominate possession and Mario Mandzukic diverted the ball wide from David Alaba's cutback.
Muller and Martinez then got in each other's way while attempting to convert a Bastian Schweinsteiger free-kick, the ball trickling wide after rebounding off the latter's thigh.
Despite Bayern's dominance, the hosts took the lead following a mistake from Neuer.
The Germany international made a mess of what appeared to be a routine catch from Kai Herdling's left-wing corner and Sule made no mistake when presented with an empty net from six yards.
Hoffenheim’s lead did not last long as Ribery's free-kick from 20 yards took a wicked deflection off Mandzukic, completely wrong-footing Casteels and nestling in the bottom left-hand corner.
Volland went close twice at the start of the seond half, volleying over Sebastian Rudy's deep cross before seeing a 20-yard effort parried wide by Neuer.
Muller then scored what proved to be the winner from close range after being set up by Ribery's quick turn and pass.
The Bayern forward wasted a golden chance to add a third four minutes from time, somehow heading Schweinsteiger's cross wide from six yards.
Schweinsteiger himself was denied by Casteels, but it mattered little as Bayern held on to extend their incredible unbeaten run.