The visitors began in a confident mood and earned the first corner of the match after five minutes.
Portugal then started to have the lions' share of possession but rarely troubled Roy Carroll in the visitors' net, with Manchester United defender Jonny Evans clearing the danger on numerous occasions.
© PA Photos
The hosts were behind after half an hour when Evans thwarted another Portugal attack before releasing Kyle Lafferty, who held the ball up before finding Niall McGinn.
The Aberdeen man dribbled into the area and lifted over the onrushing Rui Patricio to hand the underdogs the lead.
Northern Ireland almost threw away the lead when Craig Cathcart inadvertently diverted a cross onto his own crossbar but the ball bounced harmlessly clear.