Steven Fletcher netted Scotland's first hat trick in 46 years as Gordon Strachan's men bounced back from the shock of conceding Gibraltar's first competitive goal to record a 6-1 European Championship qualifying win at Hampden.
Fletcher quadrupled his international goals tally to become the first Scotland player to net a treble since Colin Stein hit four against Cyprus in 1969.
Scotland boss Strachan sprung a surprise by naming just one centre-back in his team but his three-man defence was badly exposed when Lee Casciaro raced through to strike a 19th-minute equaliser.
The goal was not the only uncomfortable moment for Scotland in the first half but, by the time the interval arrived, they had already matched Germany's four-goal haul against UEFA's newest members.
That was partly down to Gibraltar gifting Scotland two penalties, which Shaun Maloney converted, and Fletcher and Steven Naismith also calmed the nerves.
Strachan brought on centre-back Gordon Greer for winger Matt Ritchie at the break to move to a 4-2-4 formation. But, while Scotland looked more comfortable at the back, they lacked verve going forward until the final 15 minutes.
Fletcher got the first effort on target inside 90 seconds and Gibraltar goalkeeper Jamie Robba sliced a clearance behind for a corner to widespread laughter.
But the joke was almost on Scotland in the eighth minute when David Marshall had to scramble back to his line to prevent Joseph Chipolina's driven cross going straight in at his near post.
Gibraltar forced some set-pieces and Ritchie missed an opportunity to ease the tension when he shot tamely at Robba.
Scotland were gifted a penalty in the 18th minute when Robba came racing off his line to bring down Maloney near the by-line as the Scotland playmaker tried to reach 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 right 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 when on the drop 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 Lee 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.
Greer's appearance on the touchline as the second half was about to begin brought some comfort but Chipolina got the first effort on target of the second half, with Marshall fully behind his powerful drive.
Scotland looked more secure but they were struggling to create chances and Fletcher missed his kick when Hutton set him up with a low cross.
It took the introduction of Barry Bannan to spark some life into the hosts. The midfielder first set up Jordan Rhodes to shoot into the side netting with a long diagonal ball and his forward run and pass to his fellow substitute soon 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.
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.