They scraped home 17-16.
Harley’s try in his debut outing came minutes from full-time and ensured Scotland completed a clean sweep on their Southern Hemisphere tour for the first time.
In the clash of the Six Nations wooden spooners against the Pacific Nations Cup champions, Samoa recovered from a 6-7 half-time deficit to lead 16-10 midway through the second half leading to a tense closing quarter.
Scotland applied relentless pressure on the Samoa line but were held out by a spirited defence until Harley crashed over from a tap penalty five metres out from the line.
The 22-year-old Glasgow Warriors forward has frequently been Scotland’s extra player taken as a precaution on Six-Nations duty and was a late deletion from last year’s World Cup squad.
He was not required to suit up for Scotland’s opening tour matches – a 9-6 victory over Australia in atrocious wet-weather conditions followed last week by a 37-25 win over Fiji in searing Pacific island heat.
But when finally given his chance when named in the replacements to play Samoa, he came off the bench to be Scotland’s hero when he crashed over by the posts for Greig Laidlaw to land a simple conversion for the one-point victory.
Samoa, with several European-based players in their line up, opened the scoring with penalty to fly-half Tusi Pisi who produced all their 16 points in the match.
Joe Ansbro replied with try converted by Laidlaw and Pisi landed a second penalty for Scotland to lead 7-6 at the break.
Pisi and Laidlaw traded penalties early in the second half before Samoa inside centre Paul Williams found a gap between Gray and left wing Tim Visser to put Pisi in for Samoa’s sole try.
The islanders clung to their 16-10 lead for nearly 20 bruising minutes and appeared to be heading for their first win over Scotland in eight Tests before Harley’s try turned the result around. – Sapa-AFP