SAN FRANCISCO — Brandon Belt doubled to lead off the 18th inning and scored on Erik Kratz’s one-out, fielder’s choice grounder, as the San Francisco Giants beat the Colorado Rockies 3-2 Friday night.

After Belt doubled and two batters were intentionally walked to load the bases, the Rockies went to a five-man infield, bringing in center fielder Ian Desmond. Kratz hit a slow grounder to Desmond, who had to run to his left before throwing home. Belt slid in safely, but Rockies manager Bud Black immediately asked for a replay.

A brief replay confirmed the call, giving the Giants back-to-back wins for the first time this season.

Few of the announced crowd of 33,616 were still around when the 5-hour, 35-minute marathon game ended at 12:50 Saturday morning. The Giants said the game matched the longest played in Oracle Park. A postgame fireworks show began shortly after the game finished.

Travis Bergen (2-0), the ninth pitcher used by Giants manager Bruce Bochy, retired six batters and earned the win.

DJ Johnson (0-1) took the loss for Colorado. The Rockies (3-11) have lost seven straight and are off to the worst start in franchise history.

The teams combined for 41 strikeouts — 24 by the Rockies. The Giants ran out of giant “K” markers that are hung along the brick wall near right field, so three fans stood and posed like K’s after the 21st strikeout by Colorado.

San Francisco got a decent outing from starter Drew Pomeranz, but it was the Giants bullpen that made the difference, combining for 14 scoreless innings after the Rockies scored twice in the fourth.

TRAINERS ROOM

Rockies: 2B Daniel Murphy will avoid surgery and has been fitted for a new splint on his fractured left index finger after meeting with a hand specialist in Arizona. The three-time All-Star underwent a second series of tests, and the plan is to let Murphy’s finger heal on its own. Murphy signed a $24 million, two-year deal with Colorado in the offseason. . Antonio Senzatela (right heel blister infection) has rejoined the team, but no determination has been made what the next move is for the right-hander. Senzatela allowed two earned runs over seven innings in two rehab starts for Triple-Albuquerque.

UP NEXT

Madison Bumgarner (0-2, 3.32 ERA) pitches on Saturday for San Francisco, while Colorado sends Kyle Freeland (1-2, 5.40) to the mound in a matchup of left-handers. Bumgarner is winless in three starters, and the Giants have lost seven of the previous eight games that the 2014 World Series MVP has pitched in, dating to last season. Freeland is making his third road start this season.