Gibraltar scored their first ever competitive goal, but Steven Fletcher's hat-trick helped Scotland recover to win Sunday's European Qualifier 6-1 at Hampden Park.
Fletcher's treble, the first scored by a Scotland international since Colin Stein's four goals against Cyprus in 1969, combined with two first-half penalties from Shaun Maloney and a Steven Naismith strike made it a comfortable afternoon for Gordon Strachan.
But they were briefly rattled in the first half when Gibraltar striker Lee Casciaro stunned Hampden to level the game after Maloney’s opener.
The result sees Scotland draw level with Germany and Poland, who play the Republic of Ireland on Sunday evening, at the top of Group D with 10 points from their opening five games.
An experimental 3-5-2 line-up saw the Scots start with just one recognised centre-back as Alan Hutton and Andrew Robertson partnered Russell Martin at the back.
But the visitors had the first opening as Joseph Chipolina’s cross-shot almost caught David Marshall off guard, and Scott Brown was forced into a last-ditch clearance moments later.
Scotland were gifted a penalty in the 18th minute when Jamie Robba came racing off his line to bring down Maloney as the Scotland playmaker tried to reach Matt Ritchie's through-ball. Maloney dispatched the penalty into the corner but the visitors remarkably levelled a minute later.
Russell Martin failed to cut out a forward ball near the centre circle and Scotland were immediately vulnerable as left-back Andy Robertson covered for the only central defender. Aaron Pyas spotted the gap before Ikechi Anya to play midfielder Casciaro in and the policeman fired through Marshall's legs.
Scotland had an element of shell-shock about them until Fletcher restored their lead with a scrappy goal in the 29th minute.
Ryan Casciaro could only head Anya's cross up into the air and Fletcher met it to nod the ball into the corner from six yards. It was only his second goal in 20 international appearances and his first since netting against Iceland at Hampden almost exactly six years ago.
Maloney got his second in the 34th minute when he fired a penalty in the same corner of the net after Casciaro had jumped into Steven Naismith.
Fletcher flicked Ritchie's low cross against the outside of the post but Scotland's fourth came in the 39th minute. James Morrison released Anya with a pass down the left channel and the Watford player cut the ball back for Naismith to sidefoot home.
It took the introduction of Barry Bannan to spark the hosts into life after the break and his forward run and pass to fellow substitute Jordan Rhodes led to Fletcher's second goal in the 77th minute. The Sunderland striker headed Rhodes' cross into the corner of the net from six yards.
Robba made decent saves from Rhodes and Bannan before the latter set up Fletcher to curl a low shot into the corner from 16 yards in the 90th minute to seal a historic hat-trick.
Fletcher almost emulated Stein in injury-time but he fired just wide from Bannan's low free-kick and there was still time for Rhodes to miss a sitter as Scotland stayed level with world champions Germany in the race for Euro 2016.