Portugal’s defensive obduracy had frustrated Germany for 72 minutes and Gomez was about to be substituted when he planted Sami Khedira’s cross from the right past goalkeeper Rui Patricio.
Suddenly faced with chasing the game, instead of settling for the bore draw, Portugal brought Cristiano Ronaldo and Nani into the game and laid siege on the German goal.
In a barnstorming finish, goalkeeper Manuel Neuer brilliantly denied Silvestre Varela to seal the victory as Joachim Low’s men made a successful start to their quest for a first European crown since 1996.
Germany featured seven Bayern Munich players, all of whom will have felt a daunting sense of deja vu in the first half as Portugal set themselves to soak up the pressure.
Chelsea beat Bayern in the Champions League final a matter of weeks ago using exactly the same, backs-to-the-wall style that some would describe as anti-football.
Although Portugal started with Ronaldo, who has scored 112 goals in 101 appearances for Real Madrid, and Nani, they set themselves up to nullify Germany and play for the draw.
Mesut Ozil was Germany’s main attacking threat and the three-times European champions came close to an early goal with a header from striker Gomez.
Helder Postiga won a corner after a run from Fabio Coentrao, but Portugal were sitting so deep they lacked any real fluidity in attack. Ronaldo was a spectator for most of the first half.
Thomas Muller picked out Arsenal-bound Lukas Podolski, who tried a low first-time shot with the outside of his right foot that was easily saved.
Joao Pereira did well to close down Ozil, who had jinked his way into the Portugal box after being released by his Real Madrid team-mate.
Postiga became the first player booked after he chased an underhit back-pass from Mats Hummels and caught Neuer as he slid for the ball.
Neuer made an unsavoury meal of a fairly innocuous incident, simply to ensure the former Tottenham striker was shown the yellow card.
When Ronaldo finally got a chance to run at Germany, his trickery got the better of Jerome Boateng and his dangerous cross was stabbed behind for a corner.
When the cross came back in, Bruno Alves was unmarked in the box but he could not make contact with the ball and Germany escaped.
Khedira linked with Ozil to pick open the Portuguese defence with a neat one-two before he was fouled by Raul Meireles but the free-kick was drilled straight into the wall.
After 44 minutes of German dominance, it was Portugal who created the best chance of the first half.
Defender Pepe made space in the box with a delightful first touch and then curled a delightful shot over Holger Badstuber and on to the underside of the bar.
The ball crashed down onto the line and away. It was a close escape for Germany.
Meireles made two important blocks after the restart, but Portugal did offer more in attack in the second half, with Nani beating Philipp Lahm before whipping in a cross.
The ball fell to Ronaldo in the box after a driving run from Coentrao, but he was denied by Boateng’s perfectly-timed block.
With Germany unable to break the deadlock, Low was just about to take off Gomez when the Bayern Munich striker scored with a brilliant header.
Gomez rose to meet Khedira’s deflected cross from the right and directed his downward header back across goal and inside the far post.
Low reacted by instructing Miroslav Klose to sit back down and Gomez almost had a second as he galloped unmarked into the box but Muller’s cross was just ahead of him.
Portugal had to up their attacking game and threatened more in the final 10 minutes than they had in the previous 80.
Coentrao had an effort that was deflected just over the bar before Nani’s cross dipped on to the bar and away.
Nelson Oliveira pulled the ball back for Varela inside the Germany box but Neuer was off his line in a flash and blocked the shot.
Ronaldo then picked out Nani but the Manchester United forward saw his shot deflect behind off Badstuber’s shoulder as Germany hung on.