Marcus Di Rollo scored a late try against the tiring Samoans to hand Frank Hadden his first win as full-time Scotland coach in the Bank of Scotland Corporate autumn Test at Murrayfield.
Samoa opened the scoring through Alesana Tuilagi in the sixth minute but that was cancelled out by Allister Hogg's effort midway through the half.
Chris Paterson and Roger Warren traded two penalties to leave the game in the balance at 11-11 before Di Rollo stormed over in the corner after some great work from man-of-the-match Sean Lamont.
It was a far from impressive performance from Hadden's side but, on the back of the narrow defeat to Argentina last week, was a welcome victory for the new coach as he looks forward to the visit of New Zealand.
Glasgow's Rory Lamont went off in the second-half, but Hadden confirmed it was only a precaution.
His brother, former Glasgow star Sean, knows the team will have to improve as they prepare to face the might of New Zealand next weekend.
"It was incredibly tough," Sean said.
"They are big, strong boys and there was a lot of big hits out there.
"We needed the win and we eventually ground it out, which is important.
"But we will really need to up our effort for next week."