Ronaldo's three goals, two trademark headers and one from a free kick, sent Portugal back to the top of Group F and made him his country's second best goalscorer of all time with 43 goals, ahead of the great Eusebio who scored 41.
The visitors were firm favourites but Northern Ireland, who had held Portugal to a 1-1 draw in Porto last year and shocked Russia 1-0 in Belfast last month, proved tough opponents.
Before Ronaldo grabbed his first hat-trick for Portugal in the second half, they struggled to penetrate Northern Ireland's defence and it took a piece of individual brilliance from centre back Bruno Alves to break the deadlock.
Alves, a self-proclaimed lover of foot-volley, seemed to be on the beach practising the sport when, from a corner, he applied an unorthodox first-time shot with the inside of his foot that drifted into the goal after 29 minutes.
The Northern Irish harassed Portugal's defence with a series of clever long balls and were spurred on by an ardent crowd at the small but picturesque Windsor Park.
The home side kept pressing and got their reward before halftime when centre back Gareth McAuley towered above the Portuguese defence and levelled with a textbook header from a cormer.
The Portuguese were dealt a major blow just before the halftime whistle when striker Helder Postiga was shown a straight red card for a head-butt on McAuley.
Forward Jamie Ward compounded Portugal's misery by tipping in a goalmouth scramble after 52 minutes from another corner.
Portugal got back into the match when Kevin Brunt was shown a second yellow card and was also sent off, making it 10 against 10.
Ronaldo headed in another corner to make it 2-2 with 20 minutes to go and another one put Portugal in front with 77 minutes on the clock.
Northern Ireland's Kyle Lafferty was also shown a straight red card before Ronaldo completed his hat-trick with a fine free kick and took the match ball home as a souvenir.
Group rivals Russia beat Luxembourg 4-1 on Friday and are second, on 15 points with one game in hand. The Portuguese, on 17 points, host Israel and Luxembourg in the final two qualifiers in October.
- Sports & Recreation
- Northern Ireland