Last Sunday’s crushing defeat to Ireland, combined with Japan’s shock win over Joe Schmidt’s side, had left the Dark Blues on the verge of a humiliating early exit.
But their destiny know rests firmly in their own hands after thrashing the Pacific Islanders 34-0 at Kobe’s Misaki Stadium.
Sean Maitland and Grieg Laidlaw both crossed over during a frenetic first half, while Stuart Hogg split the posts with a huge drop goal to give the Scots the morale boost they needed after their shambolic display in Yokohama eight days earlier.
And two penalty tries after the break ensured the Dark Blues walked away with maximum points.
The Scots must now repeat the trick against Russia a week on Wednesday – and if they do that they can seal a place in the last eight by defeating Japan while denying the tournament hosts a bonus point in their final Pool A game.
World Rugby rules meant the retractable roof was left closed on the 30,000 seater arena, ensuring temperatures of almost 30 degrees and humidity levels above 80 per cent inside.
The Scotland players will seldom have played in conditions like this and their discomfort was obvious within minutes of kick-off as the sweat poured down their faces.
There were spills, thrills and slips from the off as both teams had to contend with the moisture coating both the ball and the pitch.
The Scots were desperate for a fast start, but all they got from the opening quarter was a ninth-minute Laidlaw penalty after Melani Matavao was pulled up for a high tackle on Magnus Bradbury.
There were moments when frustration could have got the better of Townsend’s men as their error count mounted.
Finn Russell almost put his team in trouble with a knock-on inside his own 22, while Laidlaw ruined some good work by the forwards when he overcooked a pass that even the 6ft 6ins Jonny Gray could not catch.
But the breakthrough on the half-hour mark was just what the Dark Blues needed to release the tension.
Townsend has put a greater focus on his team’s approach to kicking during this tournament and it paid off as Russell fired a high ball across for Darcy Graham to chase.
The little Edinburgh wing did well to bring it down but was immediately pounced on by a ruck of blue shirts.
With Samoa over-committed down the right, Russell tried the trick again down the opposite flank and this time there was no-one there to stop Maitland dotting down.
The try seemed to immediately wash away all the doubts that have plagued the Scots since their Ireland mauling and they struck again within four minutes.
Russell was once more the instigator, this time with a stunning line-break that was all about his dancing feet.
The Racing 92 stand-off offloaded to Jamie Ritchie who rebounded the ball back for Laidlaw. The scrum-half had Ed Fidow to beat but got a helpful bounce off the Samoa wing’s backside and stumbled over the line to score.
Scotland’s tails were up now and they added to their lead three minutes before the break as Hogg nailed a massive 40-yard drop goal to become the first Scot to do so since Duncan Weir’s last-minute winner against Italy in 2014.
They would have loved a third try in stoppage time but Samoa did just enough to survive surge after Scottish surge.
Scotland had won most of the collisions but started the second half going backwards as the Pacific Islanders fired out of the traps.
But the Dark Blues’ pack soon regained control, with their pressure bringing about a penalty try after 57 minutes as Fidow was yellow carded for illegally dragging down a rolling maul as substitute hooker Fraser Brown tried to ram his way over the whitewash.
That left plenty time to chase the fourth touchdown and the precious bonus point.
And it came with six minutes left. Maitland was released out wide by Duncan Taylor and immediately put his head down and charged for the line. He dived early, but was prevented from reaching the line by Fidow’s illegal knee-first tackle.
Referee Pascal Gauzere saw the challenge for what it was and flashed a second yellow – followed by red – at the Samoan wing before awarding the penalty try to the Scots’ delight.