Cristiano Ronaldo hit a second-half hat-trick to spare Portugal's blushes against Northern Ireland on an ill-tempered night that saw three red cards at Windsor Park.
The hosts looked to be on course for a stunning upset when Jamie Ward's scrambled effort put them 2-1 in front and a man to the good after Helder Postiga's dismissal.
But makeshift left-back Chris Brunt saw red on the hour and Ronaldo took control with a pair of powerful headers and a late free-kick, before Kyle Lafferty's dismissal completed Northern Ireland's misery.
Defenders Bruno Alves and Gareth McAuley had earlier traded first-half efforts to send the sides in 1-1 at half-time.
Ronaldo, playing for the first time since Gareth Bale replaced him as the world's most expensive player, overtook Eusebio as his country's second-highest goalscorer on the night and now has 43 for Portugal.
Injuries to Aaron Hughes, Craig Cathcart and Ryan McGivern, as well as Daniel Lafferty's suspension, had left Northern Ireland boss Michael O'Neill with limited options at full-back but even so his selection was a huge gamble.
MK Dons right-back Lee Hodson was handed the toughest task of his career in marking Ronaldo, while Brunt - a laconic attacking midfielder by trade - was installed on the other side of the back four.
Ronaldo's early touches were roundly booed by the crowd, though it was hard not to admire a wonderful piece of trickery that saw him nutmeg fellow captain Steven Davis.
The Windsor Park faithful had come prepared, though, and quickly broke into a mischievous chorus of "There's only one Gareth Bale''. The first attempt on goal took 16 minutes, Alves heading Joao Moutinho's free-kick just wide.
The same pairing combined to better effect five minutes later, Moutinho's corner cleared to the edge of the area and Alves sending a soft cushioned volley through the crowd of bodies and into the bottom corner. The goal sucked some of the intensity out of the game, with Portugal slowing
the pace noticeably.
Fabio Coentrao was the most visibly affected, almost gifting Northern Ireland a glorious chance when Hodson robbed him on the byline and just failed to find Martin Paterson.
Coentrao, who started brightly, was then left flat on his backside as Niall McGinn breezed past him on the right. Northern Ireland's pressure paid dividends in the 36th minute, with McAuley heading his side level. It came from the likeliest source - a Shane Ferguson corner - but the execution from the West Brom defender was superb.
He rose highest in a packed box and angled his header deftly towards the far post. The buoyant home fans then had more to cheer just before the break as Postiga aimed an apparent headbutt in the direction of McAuley and was shown a straight red card.
Ronaldo was furious but received a caution of his own for dissent. McAuley was having the night of his life and almost made it even more
remarkable shortly after the restart. Picking up the ball just inside the Portugal area he spotted Rui Patricio off his line and sent a deft lob a yard over the crossbar from at least 40 yards. It was an audacious moment even Ronaldo might have smiled at.
Already shaky, the 10-man Portugal were veering close to meltdown from set-pieces and it was no surprise when Northern Ireland scored their second from another corner. Ferguson was again the provider, whipping the ball into the danger area and finding Jonny Evans.
His header was on target but Ward, effectively man-marking the goalkeeper, managed to scramble home from point-blank range. There were appeals for offside, but the goal stood.
The lead was less than 10 minutes old when Brunt's dismissal made it an even playing field, a clumsy challenge on Joao Pereira earning his second yellow. Roy Carroll made a fine save to deny Miguel from 25 yards but the equaliser arrived from Moutinho's 68th minute corner.
Ronaldo shook off the attentions of substitute Lafferty to power his header past Carroll and go level with Eusebio on 41. The celebrations from the Portugal bench spoke volumes for their relief.
There was even more elation from the away contingent after 77 minutes, when Coentrao's hanging cross picked out Ronaldo at the far post. He was, unforgiveably, unmarked and headed emphatically into the corner from close range. Lafferty was next for an early bath, a senseless lunge at Pereira his sin, and the stage was set for Ronaldo.
He rifled home an 83rd-minute free-kick to secure the match ball and leave Bale with a timely reminder of the standards expected from the best in the world.