Moments before he was supposed to be taken off, Mario Gomez headed in the winning goal for Germany.
The Bayern Munich striker made a surprise start Saturday against Portugal at the European Championship and knocked in a deflected cross from Sami Khedira in the 72nd minute to give the Germans a 1-0 victory in Group B.
Gomez, who had created little before the goal, was due to be replaced by Miroslav Klose, who was already waiting on the touchline on his 34th birthday.
Gomez nearly got another goal before Klose finally came on in 80th.
Germany was the better team but found it hard to break down a defensive Portugal. The Germans, seeking their first title since 1996, are considered one of the favorites of the tournament despite being in the toughest group along with the Netherlands and Denmark.
Although Cristiano Ronaldo did little until late in the match, Portugal had a chance to equalize in the 84th when Nani hit the crossbar with a misdirected cross _ the second time the team struck the frame in the match. And Silvestre Varela had another opportunity in the 89th but he shot straight at Germany goalkeeper Manuel Neuer from close range.
Although Germany monopolized possession and chances, Pepe had the best opportunity of the first half, hitting the underside of the German crossbar late in the period after a Portugal corner. The ball hit the line and bounced out.
Despite indicating before the match that he would start the veteran Klose as striker, coach Joachim Loew went with Gomez. In another move against expectations, Loew also picked Mats Hummels as his starting center back in place of Per Mertesacker. Both Mertesacker and Klose came into the tournament after long-term injuries.
Boateng played at right back although Loew had been upset about newspaper stories about his private life.
In the end, Loew's decisions proved right. Hummels had a good game, Boateng dealt reasonably well with Ronaldo and Gomez scored the decisive goal.
Germany: Manuel Neuer; Jerome Boateng, Mats Hummels, Holger Badstuber, Philipp Lahm, Sami Khedira, Bastian Schweinsteiger, Thomas Mueller (Lars Bender, 90), Mesut Oezil (Toni Kroos, 87), Lukas Podolski, Mario Gomez (Miroslav Klose, 80).
Portugal: Rui Patricio; Joao Pereira, Bruno Alves, Pepe, Fabio Coentrao; Joao Moutinho, Miguel Veloso, Raul Meireles (Silvestre Varela, 80); Cristiano Ronaldo, Helder Postiga (Nelson Oliveira, 70), Nani.