It was the second straight win for Minnesota, which had previously lost six in a row.
Pinch-runner Caleb Hamilton started the extra inning on second base and advanced to third on a perfect sacrifice bunt by Nick Gordon. Gio Urshela walked and Max Kepler was intentionally walked before Celestino took four straight balls from Dominic Leone (4-5), San Francisco's fifth reliever of the night.
"It's easy to get carried away in that situation and just try to go out there and hack for a homer but he stayed composed. He had a good approach and he drew that walk," said Carlos Correa, who tied a career-high with four of Minnesota's nine hits.
Hamilton, Minnesota's third-string catcher, scored his first career run in his fifth career game.
"When you have ups and downs in a game, in a very tightly contested game, like it was tonight, and then you just find a way no one cares how you get it done, you just want the result. ... It took a lot of different and seemingly small individual plays today to all add up to a 'W,'" Twins manger Rocco Baldelli said.
Minnesota scored all its runs in the final two innings.
Down to its last out, RBI singles by Correa and Jake Cave off San Francisco closer Camilo Doval tied the score 2-2 in the ninth. Kepler walked to open the inning and Luis Arraez walked two outs later. Correa singled to right to drive in Kepler and Jose Miranda went the other way to score Arraez.
With Jhoan Duran (2-3) pitching, a heads up play by Correa at shortstop opened the San Francisco 10th. With Luis González trying for third base on a ground ball, Correa threw to Urshela for an easy tag.
"Yeah, right now Luis is, as he's developing into a major league player, he just doesn't trust himself enough. So, he's kind of in between and being in between on the bases is not conducive to making good reads," Giants manager Gabe Kapler said.
Correa started a near-rally in the eighth against John Brebbia, hitting a sharp single past third baseman Evan Longoria. Cave snapped an 0-for-21 skid with a single to get Correa to third, but Brebbia got Miranda to pop out and Gordon struck out for the third time.
Doval replaced Brebbia and Urshela lined out. Minnesota was 2 for 10 with runners in scoring position.
Tommy La Stella drove in an early run for the Giants, who had just four hits for the second straight night. Three of those came in the ninth before Austin Slater's sacrifice fly scored another.
San Francisco starter Alex Cobb allowed four hits while striking out seven; however, he needed 99 pitches to get through his quintet of innings, 31 in the five-batter second inning.
After Zack Littell threw a 1-2-3 sixth, Alex Young survived a shaky seventh by, first, getting Celestino to hit into a double play. Two batters later and moments before a 51-minute rain delay, Arraez flew out with a man on second and lightning nearby.
Minnesota starter Sonny Gray also put up the outs in his five-inning outing without much brevity. Of his 90 pitches, 53 were strikes.
"Not very pleased with how it went. I know that I need to be a lot better than that, and I got some things to work on. Overall, not very pleased with it," he said.
Yet Gray took a no-hitter into his final inning but walked Slater and González - Slater was picked off first base - before Joey Bart lined a double to left field for the first San Francisco hit. La Stella followed with a sacrifice fly to score González.
Gray has allowed two or fewer runs in six of last seven starts since the All-Star break, going 3-1 in that span with a 1.91 ERA. He's struck out at least five in all but Saturday's game, where his total was four.
San Francisco recalled González from Triple-A Sacramento after the Giants optioned OF Bryce Johnson to the River Cats after Friday's game.
Giants: 1B LaMonte Wade Jr. was back in the lineup. A late scratch Friday with hip tightness, he struck out three times.
Twins: 2B Jorge Polanco left the game in the sixth with left patellar tendinitis and is day to day. He'll be evaluated Sunday. ... RHP Tyler Mahle (right shoulder tightness) felt good after throwing 25 pitches in a Friday bullpen session. A more intense bullpen session is planned next, although no time has been set. He is eligible to come off the 15-day disabled list Sept. 2.