Al Strokosch plunged over for a last-minute try as Scotland edged out Italy in the final match of their South African tour.
Matt Scott and Sean Lamont touched down for Scott Johnson's side in the first half, following an early score from Italian Leonardo Sarto.
An Italy penalty try levelled the scores before the break and the Azzurri had the better of the second period.
But Greig Laidlaw converted Strokosch's late effort to secure an unlikely win.
The Scottish skipper was calmness personified as he knocked the last kick of the game between the posts to complete a faultless kicking performance.
Alberto Di Bernardo bettered Laidlaw's tally of points with 19 to the Scot's 15, but the Italian stand-off crucially missed one of the six penalties he lined up.
Johnson capped 10 new players on a tour that opened with a lacklustre loss to
Pride was restored in the following defeat by South Africa but this looked like a game too far for a patched-up squad.
In a game that opened in front of a sparse crowd, both sides appeared fatigued and Scotland certainly lacked the intensity they showed in last weekend's loss to the Springboks.
Indeed, they were dozing when Sarto eased through a huge gap to celebrate his first cap with a try in the second minute, with Di Bernardo converting.
The Scots were soon level as David Denton broke through a tackle from the tail end of a line-out and Scott showed some fancy footwork to take him over the line, with Laidlaw adding the extras.
Italy dominated the scrum and the first of several infringements in that area was punished by a successful Di Bernardo penalty.
A good flowing move, including an extravagant dummy from Johnnie Beattie, saw the Scots threaten near the posts when Scott chipped on for Denton.
The thundering back-row could not gather as ball spun awkwardly off the turf but Giovanbattista Venditti foolishly elected to run out of defence and he was soon stopped in his tracks as they ball was fed to Lamont for his 11th international try.
Despite the high altitude, Scott and Alex Dunbar were consistently puncturing the Italian defence with their darting runs and Laidlaw stroked over another penalty to establish a 17-10 lead.
A period of Italian pressure ended with a great Tim Swinson interception but Beattie fumbled the offload to halt a breakaway opportunity.
The impressive Sarto then broke two tackles on the left wing before passing to Alberto Sgarbi but the Italian centre juggled the ball over the line under pressure and Laidlaw was swift enough to gather the scraps and prevent what looked a certain score.
The Scottish scrum buckled again after big push from Italy and another two collapses followed, with Welsh referee Leighton Hodges running out of patience and awarding a penalty try. Di Bernardo was again on target with the boot.
Laidlaw got lucky when his close-range penalty went over via an upright and Di Bernardo brought the scores level at the half-time break when his kick from halfway sailed through the posts.
Laidlaw and Di Bernardo again exchanged successful penalties in the opening minutes of the second half before Italy gained the upper hand.
Coach Jacques Brunel introduced some experienced players from the bench and the tactic paid off as they opened up a gap of six points through the boot of Di Bernardo against increasingly disjointed opponents.
Scott was denied a second try when Tim Visser released him with a forward pass.
And Scotland appeared to have squandered late chances when a run from Duncan Taylor was stopped just short and Laidlaw dropped the ball when trying to go over the top of a pile of bodies.
However, with the Italians weary, Strokosch found one final burst of energy to find a gap and touch down near the posts with Laidlaw landing the crucial conversion.
Scotland: Dickinson, Lawson, Murray, Swinson, Kellock, Denton, Strokosch, Beattie, Laidlaw, Heathcote, Lamont, Scott, Dunbar, Seymour, Murchie.
Replacements: Low for Dickinson (51), Brown for Lawson (72), Welsh for Murray (73), Gilchrist for Swinson (59), Harley for Beattie (61), Pyrgos for Heathcote (49), Visser for Seymour (44), Taylor for Murchie (59).
Italy: Aguero, Garcia, Castrogiovanni, Cedaro, Bortolami, Furno, Barbieri, Parisse, Botes, Di Bernardo, Venditti, Sgarbi, Morisi, Sarto, Masi.
Replacements: De Marchi for Aguero (47), Cittadini for Castrogiovanni (49), Pavanello for Cedaro (53), Zanni for Bortolami (49), Chillon for Botes (70), Canale for Sgarbi (53), McLean for Sarto (61). Not Used: Ghiraldini.