Mario Gomez plugged away all match and ultimately came through when it mattered most as the German scored in the 90th minute Tuesday to help Bayern Munich earn a 2-1 victory in the opening leg of its Champions League semifinal tie against Real Madrid.

The German international had chance after chance throughout the 90 minutes to help Bayern claim an advantage at the Allianz Arena, but it was Franck Ribery who opened the scoring for the home side. While Mesut Ozil was able to level the score eight minutes into the second half, Gomez popped up with a crucial winner in the dying minutes to see Bayern take a one-goal edge into the second leg at the Bernabeu on April 25.

Bayern was denied an early chance at a penalty kick when Ribery easily went to ground following a slight tug from Sergio Ramos. Referee Howard Webb was not fooled and allowed play to continue.

Ribery had the last laugh though, breaking through in the 17th minute to hand Real Madrid its first deficit of the Champions League season.

A corner kick for the home side was not properly dealt with by the Madrid defense and Ribery was rushing into the box to smash home the loose ball as the Frenchman drove his effort through traffic and into the back of the net.

Real Madrid pulled level as Ozil's 53rd minute strike. The Turkish-born German capped some extensive build-up play around the box and slotted home a close- range effort off an assist from Cristiano Ronaldo.

Bayern pushed in search of an equalizer, and Gomez had several opportunities to break the deadlock, including a late shout at a penalty kick following another nervous challenge from Ramos.

But the telling goal ultimately came in the final minute of regulation when defender Philipp Lahm slid a ball in front of goal. Gomez beat his mark at the back post and stuffed the ball past Iker Casillas for his 12th Champions League goal of the campaign, dooming Real Madrid to its first loss in the competition this season.