It was the home side who took early possession of the ball, with Franck Ribery causing concern to the Madrid defence with his direct running.
Madrid looked the more dangerous as the half developed, but Bayern had a penalty shout turned down after 15 minutes when Ribery was felled in the box by Sergio Ramos, but no decision was forthcoming from referee Howard Webb.
Bayern took the lead moments later, however, when Ribery smashed the ball past Iker Casillas from close range.
Madrid ended the second period the better, but Bayern so nearly made it 2-0 five minutes before the break when Gomez stung the palms of Casillas inside the box.
Madrid might have levelled the match moments after the interval when Benzema advanced on goal, but Bayern defender Jerome Boateng was on hand to make a smart block.
Arjen Robben had a chance to extend Bayern's lead after 52 minutes, but he fired over from outside the box.
Madrid did equalise, however, after 53 minutes when Ozil tapped home from close range after good work from Ronaldo, who had missed with a effort moments before.
Bayern might have moved back into the lead after 62 minutes when Gomez advanced on goal, but Casillas pounced at the German's feet to collect the ball.
Gomez had another wonderful chance after 71 minutes, but somehow he fired over the bar from close range after a mistake from Ramos.
It was Bayern who continued to push for a winner in the latter stages of the match, with Gomez taking centre stage.
Ribery was next to come close for Bayern after 82 minutes, but he just could not sort out his feet in the area, and Pepe cleared the danger.
Gomez again headed straight at Casillas with five minutes remaining, before the German had a strong penalty shout turned down late on when he was felled in the area by Ramos.
Bayern secured the win late on, however, when Gomez converted a Phillip Lahm cross from close range to secure a lead ahead of the second leg.