New York tied the score in the ninth on an RBI single by Josh Thole but the Giants wasted no time regaining the lead.
Cabrera drew a walk to open the 10th against Frank Francisco (0-1) and stole second with one away. Nate Schierholtz was intentionally walked with two out before Sanchez hit a looping line drive to center field.
New York put runners on second and third with one away in the bottom of the 10th before Clay Hensley got Jason Bay on a strikeout and Lucas Duda on a fly ball to center. Hensley picked up his first save and preserved the win for Sergio Romo (1-0).
Angel Pagan hit a solo homer as part of San Francisco's three-run third inning. Bay and Kirk Nieuwenhuis hit solo shots for the Mets.