Germany were the more attacking side throughout but were kept at long range by some well-drilled defending by Portugal, who almost snatched the lead in the last minute of the first half when Pepe curled a precise shot against the bar but saw the ball bounce onto the line and away to safety.
The Germans continued to press and got their reward when Sami Khedira swung in a deep cross from the right and Gomes, preferred up front to Miroslav Klose, rose to power home his 23rd international goal.
Earlier on Saturday Denmark snatched a surprise 1-0 win over Netherlands in the other game in the group considered the toughest of the tournament.
Gomez's goal lit up a largely uneventful affair, dominated by packed defenses and stalemate in midfield.
Germany did well to stifle Portugal's rocket-heeled wingers Cristiano Ronaldo and Nani, who both had frustrating evenings as a disappointing Portugal threatened sporadically.
German fans caused almost as much excitement off the pitch, throwing what appeared to be rolled up pieces of paper at the Portuguese players on several occasions in the first half.
Authorities warned supporters three times that such behavior could force the match to be abandoned.
One of Germany's best chances fell to midfielder Thomas Mueller, who fired wide from a good position in the 40th minute.
The miss prompted German manager Joachim Loew to spring from the bench and shout in frustration at his players.
Germany twice tested Rui Patricio in the first 10 minutes through a header from Gomez and a Lukas Podolski shot that the keeper grabbed at the second attempt. Podolski later skied an effort well over the bar from just outside the box.
Portugal, who have scored just once in their last four matches, poured forward in the closing minutes with substitute Silvestre Varela denied by keeper Manuel Neuer.
Perhaps just as worrying for coach Paolo Bento was another subdued performance from Ronaldo, who shines for his club Real Madrid but rarely produces a truly memorable performance in big games for Portugal.