Marcus di Rollo's first international try gave Frank Hadden his first victory as full-time Scotland coach against Samoa in the autumn Test at Murrayfield.
Alesana Tuilagi shocked the home crowd with an early try for Michael Jones' side but Allister Hogg replied for the Scots midway through the first half following a well-orchestrated rolling maul from the forwards.
Chris Paterson and Roger Warren then traded two penalties each to leave the match finely balanced at 11-11 with 12 minutes remaining.
But Di Rollo muscled his way over in the corner in the 74th minute and Paterson converted to secure victory against the Pacific islanders, who pushed England close in the last World Cup but have still to defeat Scotland.
The home side, lining up with an all-new front row from the one which started against Argentina in the shape of Craig Smith, Scott Lawson and Allan Jacobsen, began in a bright and fluent manner.
But it was the visitors who struck first when Tuilagi used his strength to beat Chris Cusiter - recalled at the expense of Mike Blair - to a chip over the top from scrum-half Garrick Cowley in the sixth minute.
Hadden's men responded with a spirited thrust and were confident enough to reject the chance of three almost certain points when Samoa prop Justin Va'a was penalised for playing the ball on the ground.
A knock-on from Paterson ended that foray but, with Rory Lamont full of running and Jason White making good yards around the fringe, Scotland looked threatening.
After rejecting their fourth penalty-goal opportunity, a catch and drive saw Scotland finally reap reward when their rolling maul overpowered the Samoans and Hogg touched down in the 19th minute.
Samoa almost hit back immediately when Leicester powerhouse Tuilagi's chip ahead struck the upright but bounced, fortunately for Scotland, into the hands of lock Craig Hamilton.
From the resulting five-metre scrum and subsequent ruck, Samoa induced an infringement from their hosts and Warren - having like Paterson failed with his conversion attempt - slotted over the penalty.
Paterson drew his side level at 8-8 moments later, though, when he was successful with his first penalty attempt after the Samoans were caught offside.
Referee Alain Rolland finally tired of the way the Samoans were slowing ruck ball down and in the 33rd minute sent flanker Iosefa Taina to the sin bin.
Hadden made his first substitution at the interval when Edinburgh second-rower Alastair Kellock came on for Glasgow's Hamilton.
The Pacific islanders also made a change at lock when Jonathon Faamatuainu, making his international debut along with centre Eliota Fuimaono-Sapolu, was withdrawn and Leo Lafaialaii introduced.
Rory Lamont had to be replaced seven minutes into the half by Hugo Southwell after the Glasgow winger was taken high during the process of touching down for what he thought was a try, but which was in fact ruled out for a forward pass.
Scotland were very much in the ascendancy now, though, with Hogg, Sean Lamont and even Lawson punching holes in the Samoa defence - but just like last week they struggled to apply the finishing touch.
Indeed, when Hadden's men were awarded a 56th-minute penalty for killing the ball, Paterson gladly accepted his 400th point for Scotland - in marked contrast to captain White's earlier eagerness to kick penalties.
Blair and Phil Godman were introduced at half-back just after the hour mark by Hadden in a bid to spark the backline but 12 minutes from time Cardiff full-back Warren levelled things up at 11-11 after Scotland were caught offside.
Scotland were therefore immensely relieved when Edinburgh centre Di Rollo muscled in at the corner for his first international try six minutes later after a strong run from Sean Lamont.
With Paterson converting the home side had a seven-point cushion which they held onto for a welcome victory.