Gomez double defeats Nuremberg in derby
Gomez, who has scored seven goals in his last five league appearances, missed out on a hat-trick when he skied a penalty over the bar late in a match which also saw Franck Ribery make his return after an injury layoff of nearly two months.
Papiss Demba Cisse scored an injury-time winner, his 10th goal of the season, to give surprise package Freiburg a 1-0 win at Hoffenheim in Sunday's other game and lift them to fourth.
Borussia Dortmund, 2-0 winners over Hamburg on Friday, are top with 31 points from 12 games, seven ahead of Bayer Leverkusen and Mainz 05 with Freiburg another three behind.
Bayern's win took them up to sixth, but still 12 points behind the leaders who were described as lucky by Louis van Gaal after the match.
"They have had a lot of luck, they have scored a lot of late goals but they also have a good team," said the flamboyant Bayern coach.
"They also have good organisation, a good coach and they give everything."
Gomez opened his account after 10 minutes when he scored at the far post from Danijel Pranjic's cross, but the rest of the first half was disappointing with a Martin Demichelis header the only time that Bayern threatened again.
Nuremberg started the second half well but Julian Schieber skied one chance over the bar and hit a second straight at Jorg Butt before Bayern regained control.
In the 67th minute, Gomez ran on to Pranjic's pass, was felled by goalkeeper Raphael Schaefer and Philipp Lahm converted.
Ribery, who has been out of action since Sept. 21 with a torn right ankle ligament, came on shortly afterwards. He nearly set up a chance almost immediately, then provided the corner for Gomez to head the third.
Bayern should have added to their tally with Bastian Schweinsteiger firing wide before Gomez hit his penalty wildly over the bar - Bayern's fifth miss in their last eight penalties.
"Ribery gave a very good substitute's performance, creating two clear scoring chances," said Van Gaal.
In the other match, Senegal forward Cisse scored with almost the last kick off the game, firing into the roof of the net from 12 metres to give Freiburg the points.
Cisse is second in the scoring table, one behind Eintracht Frankfurt's Theofanis Gekas.