SAN FRANCISCO (AP) - Denard Span singled home Gorkys Hernandez with two outs in the 14th inning, lifting the San Francisco Giants over the Colorado Rockies 4-3 on Tuesday night.

The Giants went cold after Kelby Tomlinson's tying single in the eighth inning before rallying to win off Chad Qualls (1-1).

Hernandez lined a one-out double over the head of left fielder Ian Desmond. After Qualls struck out Gearrin, Span hit a 1-0 pitch into right field, and Hernandez scored easily with a head-first slide.

The Giants raced out of the dugout and chased Span into the outfield, celebrating their second straight win over Colorado after nine consecutive losses to their NL West rival.

Gearrin (2-2) pitched three scoreless innings to win after the Giants rallied from a 3-1 deficit.

Span had three hits and two RBIs, and Hernandez and Brandon Belt each had two hits.

Mark Reynolds hit his 19th home run for the Rockies. Colorado had runners on base in each of the final five innings, including three on second base, but failed to score.

(Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)