Tonga piled the pressure on Scotland's head coach, Andy Robinson, with this battling comeback victory in Aberdeen.
Tries from Lua Lokotui and Fetu'u Vainikolo plus 11 points from the boot of Fangatapu Apikotoa earned them a memorable victory against a blunt Scottish side who led 15‑10 with 15 minutes to go, thanks to Greig Laidlaw's five penalties.
This was a third defeat of the EMC Test series, but losses to New Zealand and South Africa were a far cry from this poor performance against a side who lost to Italy, but beat the United States this month.
Robinson had rung the changes in the face of injuries and Scotland lacked ideas to overcome their physical opponents, who had three players sin-binned but were deserved winners.
Apikotoa kicked Tonga ahead after Scotland killed the ball but Laidlaw levelled with a penalty that went over via the post.
Concerted Scotlad pressure saw them pile over the line, but it was impossible to rule whether the ball was grounded beneath a heap of bodies. At least they had not fumbled the ball that time.
Tonga continually infringed and the referee, Mathieu Raynal, lost patience when Lokotui obstructed Richie Gray at a lineout and was sent to the sin-bin. Prop Halani Aulika was lucky not to join him after body-checking Matt Scott.
Tonga's short-handed scrum was penalised and Laidlaw's successful kick give Scotland a narrow half-time lead.
Laidlaw extended that lead to six points, but Tonga kept up the pressure and Lokotui burrowed over. Apikotoa converted to put Tonga 10-9 ahead. Laidlaw kicked two more penalties to give the hosts a five-point lead, but again Tonga went wide, this time Vainikolo scoring.
Nili Latu became the second Tongan sin-binned 11 minutes from time, but Apikotoa kicked his third penalty to leave the hosts requiring a converted try to win with six minutes left. Sione Timani was sin-binned, temporarily reducing Tonga to 13 men but they clung on.
Scotland: S Hogg (Glasgow Warriors); S Lamont (Glasgow Warriors), M Evans (Castres), M Scott (Edinburgh), T Visser (Edinburgh); G Laidlaw (Edinburgh), H Pyrgos (Glasgow Warriors); R Grant (Glasgow Warriors), S Lawson (London Irish), E Murray (Worcester Warriors), R Gray (Sale Sharks), A Kellock (Glasgow Warriors), A Strokosch (Perpignan), K Brown (Saracens, capt), D Denton (Edinburgh). Replacements: D Hall (Glasgow) for S Lawson 51, G Cross (Edinburgh) for E Murray 51-53, R Lawson (Newcastle Falcons) for Pyrgos 52, J Barclay (Glasgow Warriors) for Denton 53, N de Luca (Edinburgh) for Evans 59, T Heathcote (Bath) for Laidlaw 67.
Tonga: V Lilo (Bordeaux); F Vainikolo (Highlanders), S Hufanga (Newcastle Falcons), S Piukala (Eastwood), V Helu (Roma); F Apikotoa (Tautahi Gold), T Moa (Bay of Plenty); S Taumalolo (Chiefs), A Taione (Western Force), H Aulika (Highlanders), J Tu'ineau (Highlanders), T Lokotui (Japan), H T-Pole (Ricoh Black Rams), N Latu (NEC Green Rockets, capt), V Ma'afu (Blues). Replacements: T Mailau (Stade Montois) for Aulika 45, S Mafi (Leicester Tigers) for T-Pole 51, A Fatafehi (Lyon) for Hufanga 67, I Ma'asi (Leeds) for Taione 70, S Timani (Scarlets) for Tuineau 75, V Iongo (Scarlets) for Helu 75.
Referee: M Raynal (France).