SAN FRANCISCO | Carlos Gonzalez blooped a tiebreaking, two-run single with two outs in the 12th inning, lifting the Colorado Rockies past the San Francisco Giants 5-3 on Thursday night in the clubs’ first meeting of the year.

Giants manager Bruce Bochy and shortstop Brandon Crawford were ejected in the bottom of the 12th after Crawford was called out on strikes and argued with plate umpire Chris Segal.

Gonzalez connected off Cory Gearrin, who relieved after Pierce Johnson (2-2) allowed one-out walks to pinch-hitter Chris Iannetta and Charlie Blackmon.

Jake McGee (1-2) pitched two scoreless innings for the win, and Wade Davis finished for his 16th save with the tying run on first.

Colorado squandered earlier chances.

The Rockies got consecutive two-out singles in the 10th by Gerardo Parra and Nolan Arenado before Tony Watson got Gonzalez to ground out. In the 11th, Trevor Story singled before Johnson induced a double play and strikeout.

In the ninth, Crawford hit a two-out single that bounced off the outstretched glove of pitcher Adam Ottavino then Crawford stole second for his first stolen base of 2018 but the Giants couldn’t capitalize.

Brandon Belt hit his 10th home run to tie the game at 3 in the sixth, but his trot came after a replay review that sent him home from second on what initially was called a double. Belt’s ball hit off the top of the arcade in right-center. Buster Posey first scored on the play to make it 3-2.

Belt homered in a fourth straight game for the second time this season, the first Giants player to do so since home run king Barry Bonds in 2004. Randy Winn was the previous Giant to hit homers in four consecutive games, from Sept. 16-30, 2005.

Daniel Castro’s two-run double and an RBI single by starting pitcher Chad Bettis put Colorado ahead 3-0 in the second.

The first meeting between the clubs arrived at last in mid-May after the Giants already faced the division rival Dodgers 11 times. This one came on a blustery night by the bay — in fact, the umpires’ pants flapped hard in the wind early on.

Bettis struck out five and walked two over six innings, surrendering three runs and five hits. He had a second consecutive no-decision.

Giants right-hander Jeff Samardzija allowed three runs on five hits over 6 2/3 innings, struck out three and walked three in his second straight no-decision and third in the last four starts.

WARRIORS STAR

Golden State All-Star Klay Thompson tipped his cap and waved when introduced before the top of the fifth. He and the defending NBA champion Warriors host Houston in Game 3 of the best-of-seven Western Conference finals Sunday with the series tied at 1-all.

TRAINER’S ROOM

Rockies: All-Star 2B DJ LeMahieu, on the 10-day disabled list with a sprained left thumb that includes a small fracture, hopes to swing and play catch in a week. Specialists don’t believe he will need surgery. “It’s going to be OK, in time,” manager Bud Black said. “We don’t know how long.” LeMahieu was injured last Sunday on a swing during a loss to Milwaukee. He was batting .279 with five home runs and 13 RBIs.

Giants: RHP Mark Melancon threw a 20-pitch simulated game as he works back from a strained flexor tendon in his pitching elbow. If Melancon feels good Friday, he would start a rehab assignment Sunday or Monday that will likely last about two weeks, or five or six games. Bochy wants him to pitch in back-to-back games during that process. … Melancon hit rehabbing Mac Williamson (concussion) with a pitch at one point but Williamson is fine. … LHP Madison Bumgarner (broken pinkie on pitching hand) played long toss and is set to throw an extensive bullpen session Saturday of about 40 pitches. On Tuesday in Houston he is scheduled to face live hitting for the first time. … LF Hunter Pence is working on a new swing as he rehabs his sprained right thumb. Bochy expects him to have 40 or so at-bats during his rehab assignment with Triple-A Sacramento.

UP NEXT

Rockies: LHP Kyle Freeland (3-4, 3.42 ERA) is 3-1 over his last four starts and has pitched into the seventh in each one. He has 13 strikeouts in his past two road outings.

Giants: LHP Derek Holland (2-4, 4.79) lost in his only previous appearance vs. Colorado, allowing seven runs and seven hits in four innings last Sept. 7 at Coors Field.