The Zaragoza striker struck to spare Paulo Bento's blushes after a battling display from the Green and White Army looked to have earned a shock victory.
Michael O'Neill's side travelled to Porto with eight players out injured and Gareth McAuley suspended, but managed to take the lead after half an hour through McGinn, as Portugal was caught napping at the back.
Portugal rallied and spent the rest of the encounter attacking, but the hosts never looked too likely to score as Ronaldo floundered and their defense looked increasingly shaky.
Northern Ireland had been adventurous all night - especially considering the under-strength lineup - and the visitors' positive outlook paid off when Jonny Evans won the ball in his own half, burst forward and picked out Kyle Lafferty. The Sion forward advanced on the home defense before picking out McGinn, who was completely free on the left after outpacing Joao Pereira, to take a touch and fire over Patricio to record his first competitive goal for the Green and White Army.
The visitors had to ride their luck following the goal, with Aaron Hughes almost heading into his own net before Craig Cathcart crashed Pereira's cross past Roy Carroll, only to see the ball come back off the crossbar.
Later on, Ronaldo had a 30-yard effort blocked by the imperious Evans, but went closer after 58 minutes when his half-volley from around the penalty spot was saved smartly by Carroll. The goalkeeper also did well to keep out a long-range effort from halftime substitute Ruben Amorim, and moments later Steven Davis almost sliced Pepe's weak cross over his own goalkeeper.
Ronaldo went close again with 20 minutes on the clock, but Hughes was on hand to get in a timely block as the Real Madrid forward set his sights on the elusive equalizer.
Postiga fired a shot straight down the throat of Carroll on 76 minutes, before stretching the keeper again three minutes later. But the Zaragoza striker went one better seconds afterwards when the ball fell to him inside the six-yard box. After Nani failed to make proper contact with Bruno Alves' header, Postiga brought it down, swivelled and stroked in the equalizer to the sheer delight of the home fans.
It has been a disastrous couple of games for Portugal, however. Following defeat against Russia on Friday, the Portuguese have taken just one point from two games and they now have a big job on their hands to make it to Brazil 2014.