Michael O'Neill's side suffered a disappointing EURO 2020 qualifying defeat to Netherlands but bounced back in style with a superb opening 45 minutes.
McNair got proceedings underway with a fine finish in the ninth minute before Jonny Evans doubled the advantage midway through the opening period.
The impressive McNair scored a second five minutes prior to the break before the hosts set up a tense finale with two goals in as many minutes from Vladimir Darida and Alex Kral in the second half, but the away side saw out the win.
The visitor started with a spring in its step and powered into a ninth-minute lead.
Liam Boyce's pass from the left wing found McNair on the edge of the penalty area and the Middlesbrough midfielder took a touch past Ladislav Krejci before slotting into the bottom-right corner.
They deservedly doubled their advantage midway through the first half when Evans reacted quickly after a goalmouth scramble from a corner to scoop home his fourth international goal.
McNair then scored his second after 40 minutes, latching onto Steven Davis' throughball before rounding the onrushing Jiri Pavlenka and slotting into an empty net.
The hosts improved markedly after the restart and reduced the deficit with quick-fire goals in the 67th and 68th minutes.
First, Darida crashed an effort into the roof of the net from Zdenek Ondrasek's lay-off before Kral superbly whipped into the bottom corner from 18 yards after turning inside Craig Cathcart.
The resurgent hosts did most of the pressing in the closing stages – Ondrasek rightly seeing a goal ruled out in stoppage time after he had bundled the ball out of Michael McGovern's hands – but Northern Ireland ultimately held on for an impressive win on the road.