Windsor Park was bouncing when Jamie Ward's first international goal put Northern Ireland 2-1 ahead of Paulo Bento's star-studded side, who were down to 10 men following Helder Postiga's 43rd-minute red card.
But a famous win went begging when Chris Brunt - deployed out of position as an emergency left-back - was shown a second yellow card after an hour.
Real Madrid star Cristiano Ronaldo took his cue to grab the game by the scruff of the neck and claimed a hat-trick to seal the win.
Kyle Lafferty earned the third red card of the match for a clumsy challenge on Joao Pereira, with O'Neill left to reflect on what might have been.
"I'll look back on this game for a long time as the one that got away," he said.
"Of course I'm disappointed...I thought the performance in the first half was really good - we had tempo, energy, work-rate - all the things we saw when we beat Russia last month were there again.
"We were 2-1 up and in a great position in the game. It looked more likely to go to 3-1 than 2-2, but when it became 10 versus 10 and then 10 versus nine there was too much space on the pitch.
"It was a bit of a lifeline for them, Brunty's sending off, and in the last 20 minutes they showed their class."
O'Neill was relatively forgiving towards Brunt, partly because he had been asked to fulfil an unfamiliar role in the back four, but was positively seething with Lafferty.
Source: PA
Source: PA