SAN FRANCISCO — Willie Calhoun hit a tiebreaking sacrifice fly after the Giants walked the bases loaded in the seventh inning, Joey Gallo followed with a three-run home run and the Texas Rangers beat San Francisco 9-5 on Sunday to avoid a three-game sweep.

Shin-Soo Choo also went deep for Texas. Scott Heineman had a pair of hits including a two-run double and Jeff Mathis added an RBI single.

“That’s one thing that we haven’t been able to do, we haven’t been able to capitalize and finish off some of these rallies,” Rangers manager Chris Woodward said. “We still put ourselves in a situation late in the game, too, to keep pounding at them. We could have broke that game wide open with another big hit. That’s what we want to be as an offence.”

The Rangers entered the day last in the AL in scoring and hits before getting season-highs in both against the Giants.

Texas broke the game open with a four-run seventh after San Francisco scored three in the sixth to erase a 5-2 lead.

They got some help from San Francisco’s bullpen, too, when reliever Andrew Triggs (0-1) walked three consecutive batters on 14 pitches to open the seventh. After Calhoun’s sacrifice fly off Tyler Anderson made it 6-5, Gallo crushed an 0-2 pitch to right-centre.

Gallo also singled, doubled and walked.

“To answer with runs after they put up a pretty big inning and started to get momentum on their side, you could feel as soon as we scored that four runs in the seventh that the game started to change,” Gallo said. “It was a huge boost for us.”

Jonathan Hernandez (2-0) retired six batters to win.

Evan Longoria and Chadwick Tromp homered for San Francisco. Tromp’s was the first of his career, Hunter Pence tripled to snap a season-opening 0 for 23 funk.

“We had real good energy, particularly on the offensive side of the ball,” Giants manager Gabe Kapler said. “We’ve shown the ability to come back in a game. That’s very encouraging. We’ve shown some resilience.”

Choo pulled his second home run of the season over the right field wall into McCovey Cove off Giants starter Jeff Samardzija in the fifth. On Friday the Rangers leadoff batter hit an opposite field homer on the game’s first pitch.

Texas also got an encouraging outing from lefty Kolby Allard in his first start. Allard allowed one run and two hits before coming out after throwing 75 pitches in four innings.

Samardzija gave up five runs and seven hits in 5 2/3 innings and became the first Giants pitcher to make it through five innings, though he did have a blister on his pitching hand.

“No excuses,” Samardzija said. “That’s the way it goes. You have to learn to adjust and make adjustments.”

GIANTS SEND HAMILTON TO METS

The Giants traded outfielder Billy Hamilton to the Mets in exchange for right-hander Jordan Humphreys. Humphreys was immediately optioned to San Francisco’s Alternate Training Site.

Hamilton signed with the Giant in the off-season but was not on the team’s opening day roster.

“We recognize the value of having extra bats and extra arms in the (bullpen), and that just kind of made Hamilton a tougher fit, particularly with us going down to a 28-man roster size later this week,” Kapler said.

ROSTER MOVES

Triggs was called up from the Alternate Training Site before the game. RHP Jandel Gustave was designated for assigment.

Texas called up infielder Anderson Tejeda.

QUOTABLE

“It will get better. It will improve. I just think 2020 was meant to kind of test us all, especially right now. It’s just another test that we’re going to have to get through.” –Woodward

TRAINER’S ROOM

Rangers: Woodward is hopeful that 2B Rougned Odor will be available for Tuesday’s game in Oakland. Odor left Saturday’s game with tightness in the oblique area on his right side. … OF Danny Santana was placed on the 10-day injured list with a right forearm strain. Santana is 1 for 17 and has not played since Tuesday.

Giants: LHP Drew Smyly was placed on the 10-day injured list with a left index finger strain. Smyly had seven strikeouts in four innings Saturday before leaving because of discomfort in the finger.

UP NEXT

Rangers: Texas will remain in the Bay Area and begin a three-game series at Oakland on Tuesday. LHP Lance Lynn (1-0, 0.00) starts the opener. Texas won in both of Lynn’s previous two starts this season.

Giants: No starter has been announced for Monday’s game in Colorado.

__

More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP_Sports