Chris Coleman's slim hopes of making the play-offs for World Cup 2014 took a huge blow as, despite the Arsenal midfielder's penalty, a Gareth Bale-less team were beaten in Skopje
Cedomir Janevski's men had collected just four points from their previous six games but are now above both Wales and Scotland in Group A of the European qualification section thanks to Aleksandar Trajkovski's 80th-minute winner in Skopje.
Ivan Trickovski gave Macedonia the lead in the first half before Aaron Ramsey equalised from the penalty spot but 21-year-old forward Trajkovski had the final say at the Philip II Arena with a brilliant finish from the edge of the area.
Both sides made two changes from their previous matches, with Janevski bringing in Darko Tasevski and Jovan Kostovski for Ostoja Stjepanovic and Adis Jahovic after their friendly win over Bulgaria in August.
Meanwhile, Chris Coleman replaced injured midfielder Joe Allen with David Vaughan, while Ramsey started ahead of the suspended Hal Robson-Kanu.
Gareth Bale, fresh from his reported world-record transfer to Real Madrid, was named on the visitors' bench as he continues his recovery from a foot injury.
Coleman's men started the game brightly and carved out the first clear-cut opportunity after 10 minutes but teenager Johnny Williams was foiled by home goalkeeper Tomislav Pacovski after latching on to Joe Ledley's slide-rule through-ball.
Pacovski was again called into action shortly after when he saved a tame Craig Bellamy effort and the visitors were punished for failing to make their dominance pay on the 20-minute mark.
Agim Ibraimi's shot on goal from a free kick fortuitously deflected off the wall into the path of Trickovski and the striker finished smartly past Boaz Myhill to give Macedonia the lead.
Bellamy almost drew the visitors level eight minutes later when his superb curling free- kick from 25 yards rattled off the woodwork with Pacovski beaten.
However, Wales did not have to wait long to restore parity, as Trickovski undid his good work in opening the scoring by rashly bringing Ramsey down in the area on 37 minutes. Referee Sascha Kever had no choice but to point to the spot and Ramsey duly picked himself up to slot the home from 12 yards to send the sides in all square at the break.
Wales continued to control proceedings immediately after half-time and Jack Collison spurned a good opportunity to put them ahead in the 50th minute when he side-footed wide after being set up by Ramsey in the penalty area.
Despite the away side's dominance, Macedonia threatened on the counterattack and captain Goran Pandev could have restored their advantage just after the hour but could only fire past the post.
Trickovski then had a great chance to make amends for conceding the penalty when a swift break ended with the 26-year-old one-on-one with Myhill but he was denied by the West Brom goalkeeper after looking certain to grab his second of the game.
However, Trajkovski did beat Myhill with just 11 minutes remaining as he collected the ball 20 yards out and drove a low shot into the bottom corner to give the home side all three points.