Nine-man Northern Ireland held out against 10-man Wales after a furious encounter at the Millennium Stadium.
Italian referee Domenico Messina sent off Michael Hughes and Robbie Savage after an eighth-minute clash.
Jeff Whitley put the visitors ahead, then David Healy scored after a James Collins slip - only to be sent off for an over-exuberant goal celebration.
John Hartson headed the home side back into the game and sub Robert Earnshaw nodded in the second-half equaliser.
A fiery start saw both sides reduced to 10 men in the eighth minute as Savage ran the ball from deep in his own half.
The Birmingham midfielder was hacked down from behind by Hughes and retaliated by grabbing his opponent's shorts.
Hughes pushed Savage to the ground and Messina immediately brandished the red card at both players, Savage greeting the first dismissal of his colourful career with a flood of tears.
The dismissal also means that Savage will now miss next month's game with England.
Two minutes later and Northern Ireland were ahead when a long ball was headed out by Collins, but straight into the path of Whitley.
The midfielder struck a sweet right-footed snapshot from the edge of the area into Paul Jones' left corner.
Wales went close with a Jason Koumas free-kick and a Ben Thatcher volley, but were dumb-struck when youngster Collins - forming a new-look centre-half partnership with Danny Gabbidon - slipped to allow Healy in.
Healy was dismissed immediately after his goal
The striker chipped Jones, who got a hand to the ball but could not stop it as Healy raced on to nod into an empty net.
The visitors' wild celebrations were cut brutally short, though. Healy kicked over the corner flag then pumped his arm in triumph in front of the Welsh section of the crowd, and was amazed to turn and be dismissed for two yellow-card offences.
Mark Hughes then brought on Earnshaw for right-back Mark Delaney and the gamble paid off as a Craig Bellamy chip from just outside the box found Hartson who buried his header into the corner from 10 yards.
Wales continued their relentless pressure into the second half, but were looking increasingly desperate.
They were nearly caught out on 60 minutes as a sharp counter-attack from the visitors saw Tony Capaldi denied by a smart Jones save.
The visitors were looking likely to claim a breakaway goal, but Wales' ambition paid off after 74 minutes when John Oster
sent in a cross from the right.
Collins failed to convert a late chance to win the game
The diminutive Earnshaw leapt high from the penalty spot to head in his eighth goal in 15 internationals.
Both sides were looking out on their feet, but the goal lifted Wales for a final push.
The final chance slipped away on 87 minutes when Bellamy fired the ball across the face of the goal, but Collins failed to connect cleanly and his sliding effort hit the side netting.
The result leaves Wales' qualification hopes in tatters with just two points from an opening two qualifying games which were regarded as amongst their easiest ties.
Wales: Jones, Delaney (Earnshaw 28), Collins, Gabbidon,
Thatcher (Parry 63), Oster, Savage, Speed, Koumas, Bellamy,
Subs Not Used: Melville, Page, Pembridge, Taylor, Crossley.
Sent Off: Savage (9).
Goals: Hartson 32, Earnshaw 75.
Northern Ireland: Taylor, Aaron Hughes, Murdock, Williams,
Capaldi (McCartney 90), Johnson, Clyde, Whitley,
Michael Hughes, Healy, Quinn (Smith 57), Smith (McVeigh 89).
Subs Not Used: Carroll, Craigan, Jones, Elliott.
Sent Off: Michael Hughes (9), Healy (22).
Booked: Quinn, Taylor, Capaldi.
Goals: Whitley 11, Healy 21.
Ref: Domenico Messina (Italy).