The Scots may have thought that their chance of a comeback had gone when Weir missed the conversion to Henry Pyrgos's 73rd-minute try to leave them trailing 18-19.
However, Weir would be given a second shot at glory after an Argentine error from a lineout, and he took it to snatch the visitors victory from a contest in which they had been behind since the 26th minute.
It was Scotland who took the lead, though, when Tommy Seymour offloaded for Stuart Hogg to cross the line on seven minutes, with Weir adding the kick before the Pumas replied with their own early try.
The Pumas reached half-time with an 8-7 advantage, which was soon extended by Sanchez's boot, and the Argentine number 10 and Weir then exchanged penalties as the scores moved to 14-10.
Joaquin Tuculet contributed what appeared as though it would be the decisive score on the hour mark when he held off Sean Maitland to cross for the hosts' second try, although Sanchez could not add two more.
It proved to be a costly miss as Scotland rallied late on, with substitute Pyrgos bringing them to within a point, only for Weir to waste the conversion, before completing the comeback with a 79th-minute kick.
Vern Cotter's side have now beaten Argentina, Canada and the United States in their last three matches.