Scotland needed an 80th minute penalty from Ruaridh Jackson to edge past Samoa 19-16 at Pittodrie on Saturday.
After the 49-3 defeat by New Zealand and a 21-17 win over South Africa, Scotland were seeking a fifth win from six Tests to finish the year on a high.
But they were tested to the full by Samoa and had to come from behind to take a 13-10 half-time lead.
After Dan Parks' early penalty, Kahn Fotuali'i's fine ninth-minute converted try put Samoa ahead, but Nikki Walker touched down under the posts for Scotland's first try of the three-match autumn series.
Parks converted and added another penalty, but Paul Williams narrowed the deficit with three points of his own.
Williams twice kicked Samoa level with penalties either side of a Parks drop goal but 15 years after drawing with Scotland, Samoa were denied.
Replacement fly-half Jackson, aged 22 and winning his second cap off the bench, stepped up to give the hosts victory after Iosefa Tekori was penalised at the breakdown.
Allan Jacobsen and Sean Lamont won their 50th caps as Scotland looked to end 2010 on a high at Pittodrie.
But Samoa, too, were looking to end their year on a winning note after a 20-10 loss to Ireland and a 26-13 defeat by England.
Scotland had won five and drawn one - in November 1995 - of their previous six meetings with Samoa, who last recorded a European win in 2001 in Italy, but had previously defeated Wales and Ireland.
Scotland, reverting to the white change strip they wore in the humbling by the All Blacks a fortnight ago, immediately began by applying forward pressure on the Samoa line and Parks' early penalty gave the hosts a 3-0 lead.
But Samoa went in front after nine minutes, breaching the Scotland defence with a move which demonstrated their full range of talents.
George Pisi broke down the left and kicked on, Seilala Mapusua picked up and fed inside to scrum-half Fotuali'i to score. Williams converted.
Scotland responded with a converted try of their own.
After a scrum on the right, Walker burst through on an angled run off his right wing and touched down under the posts.
Walker scored two tries the last time Scotland played in Aberdeen, against Canada in 2008, and touched down for his fifth international try - the first Andy Robinson's side have scored in the autumn series.
Parks, who had a 100 per cent success rate against South Africa, missed a penalty before being granted another opportunity after Ross Ford had initiated a driving maul.
Williams cut the interval deficit to three points with a penalty after Kelly Brown was penalised for not rolling away from a tackle on Alesana Tuilagi.
The full-back levelled two minutes into the second half.
Parks missed a second straightforward penalty of the game as he failed to restore Scotland's lead.
The hosts then spread the ball the width of the field trying to puncture a hole in the Samoa defence, but no break was forthcoming and Parks dropped a goal to make amends for his missed penalty and keep the scoreboard ticking over.
Scotland were on the defensive from the restart and Samoa were continually held up short of the hosts' line.
The hosts creeped offside and Samoa drew level again with Williams kicking a penalty from in front of the posts.
Robinson turned to his bench for reinforcements with 20 minutes remaining, with scrum-half Mike Blair, prop Moray Low, fly-half Jackson, lock Jim Hamilton and centre Max Evans coming on.
Blair was immediately required in defence and caught Ofisa Treviranus in the corner, denying Samoa a second score.
Graeme Morrison, Blair and John Barclay drove through the middle as Scotland responded, but Lamont knocked on down the blindside to save Samoa.
Lamont was forced off, with Vernon switching to the wing for the final six minutes and Ross Rennie coming into the back row.
But Scotland's frailties out wide were not exposed and Samoa replacement Iosefa Tekori was penalised at the breakdown in the last minute, handing Scotland an opportunity to steal victory.
And Glasgow Warriors number 10 Jackson stepped up to convert the resulting penalty with his first points in international rugby.
Pens: Parks 2, Jackson
Pens: Williams 3
Scotland: 15 Hugo Southwell, 14 Nikki Walker, 13 Joe Ansbro, 12 Graeme Morrison, 11 Sean Lamont, 10 Dan Parks, 9 Rory Lawson (c), 8 Richie Vernon, 7 John Barclay, 6 Kelly Brown, 5 Richie Gray, 4 Nathan Hines, 3 Euan Murray, 2 Ross Ford, 1 Allan Jacobsen.
Replacements: 16 Dougie Hall, 17 Moray Low, 18 Jim Hamilton, 19 Ross Rennie, 20 Mike Blair, 21 Ruaridh Jackson, 22 Max Evans.
Samoa: 15 Paul Williams, 14 David Lemi, 13 George Pisi, 12 Seilala Mapusua, 11 Alesana Tuilagi, 10 Tasesa Lavea, 9 Kahn Fotualii, 8 George Stowers, 7 Manaia Salavea, 6 Ofisa Trevarinus, 5 Kane Thompsen, 4 Filipo Lavea Levi, 3 Census Johnston, 2 Mahonri Schwalger (c), 1 Sakaria Taulafo.
Replacements: 16 Ti'I Paulo, 17 Anthony Perenise, 18 Iosefa Tekori, 19 Afa Aiono, 20 Junior Poluleuligaga, 21 Daniel Leo, 22 Fautua Otto.
Venue: Pittodrie, Aberdeen
Referee: Steve Walsh (Australia)
Assistant referees: Marius Jonker (South Africa), Cobus Wessels (South Africa)
Television match official: Tony Redmond (Ireland)