The two sides started slowly, with Ikechi Anya's runs down the left flank the only bright sparks in the opening minutes.
The Scots gradually grew in confidence as Barry Bannan and Anya both started to put crosses into the hosts' penalty area.
However, the first chance of the game for the visitors came only in the 26th minute when Anya swung in a cross into the Macedonian box, but Steven Naismith headed it over from close range.
Pacovski was called into action again in the 44th minute when he was forced to keep out a curling effort from Anya, while moments later Macedonia put Scotland under pressure as Adis Jahovic hit the side-netting from a good position.
Gordon Strachan's side broke the deadlock in the 59th minute through Anya, who was released by Bannan and kept his cool in a one-on-one situation with the Macedonian goalkeeper.
The home team could have restored parity on 70 minutes had Ivan Trickovski been better with his first touch in front of goal.
However, there was still more drama to come in Skopje as Shaun Maloney scored Scotland's winner in the 87th minute with a direct free kick.