Martin Skrtel’s own goal in the 89th minute sparked joyous scenes and leaves Scotland second in Group F on 17 points, six behind group winners England after leapfrogging Slovakia and Slovenia, who lost 1-0 at Wembley.
A packed Hampden Park saw the in-form Scots, with Sheffield Wednesday’s Barry Bannan and Stoke’s Darren Fletcher in for the injured Celtic pair Scott Brown and Stuart Armstrong, start brightly.
They had an early penalty appeal waved away when Celtic’s Kieran Tierney tumbled in the box.
Midway through the first half Martin Dubravka in the Slovakia goal produced an eye-catching save to keep out a headed effort from Christophe Berra but the key moment came in the 23rd minute when Robert Mak was shown a second yellow card for simulation.
Despite their man advantage, Scotland, wearing pink, could not force a breakthrough, with Dubravka making impressive saves from Leigh Griffiths either side of half-time.
As tension mounted inside the stadium, the home side twice hit the woodwork.
Substitute Chris Martin rattled the crossbar with a long-range strike and Griffiths did the same with a free-kick before an inspired Dubravka denied James Morrison from just six yards out.
But just when it seemed they would fail to punish Slovakia, subs Ikechi Anya and Martin combined, putting Skrtel under pressure and he inadvertently put the ball into his own goal.
“There was no doubt that their man of the match was their goalkeeper — and the crossbar as well — and the footballing gods have decided to give us the victory,” a relieved Strachan told Sky.
Scotland travel on Sunday to Slovenia (who currently have 14 points), where they will hope to secure a result that will leave them among the eight best runners-up out of the nine European groups for Russia 2018.
Slovakia will play bottom-of-the-table Malta, on the same evening, confident of a victory that would take them to 18 points.
Gordon Strachan’s men started their qualifying campaign slowly, with just four points from their first four matches but have turned things around with 13 points from their past five games.
Download our app and read this and other great stories on the move. Available for Android and iOS.