"It certainly wasn't our best performance, but we've won it," Guardiola said after his team regained a one-point lead at the top of the table.

"Not everything was perfect, and we'll need to correct the way we're playing. Meetings with Hoffenheim in recent years have always been close, but we did have a little bit of luck today."

The pressure was on Bayern following second-placed Borussia Dortmund's 6-1 hammering of Stuttgart on Friday.

The home side had scored more goals this season than any other in the Bundesliga, and extended that when 18-year-old defender Niklas Sule became the youngest player in Hoffenheim history to find the back of the net.

However, Bayern equalized before halftime when Croatia striker Mario Mandzukic deflected in Franck Ribery's low free-kick for his eighth in the league this season, and the Frenchman was also involved as Thomas Muller scrambled a second-half winner from close range.