Gregory Polanco added an RBI triple for Pittsburgh, which snapped a four-game skid.
"You don't score three runs very often without a hit. It's a testament to our group," Pirates manager Derek Shelton said. "We had given up two runs, given up the lead and they came right back. These guys get after it. They made something happen without getting a hit and we ended up winning."
It was 3-all when Dominic Leone (2-1) walked Jacob Stallings leading off the seventh and Kevin Newman reached on a fielder's choice when shortstop Thairo Estrada's throw to second was late.
After pinch-hitter Wilmer Difo walked, Frazier worked a 2-2 count before Leone threw consecutive pitches well out of the strike zone to force in Stallings.
The Pirates added a pair of unearned runs later in the inning when first baseman LaMonte Wade Jr. fumbled Ben Gamel's two-out grounder while trying to throw the ball to pitcher Jarlin García covering the bag.
"Just trying to score runs any way you can, that's the name of the game," said Reynolds, who struck out before Wade's costly error. "Doesn't matter ultimately if you score it on a homer or something crazy happens."
Chris Stratton (3-0) retired two batters. Richard Rodríguez pitched the ninth for his 14th save.
Steven Duggar and Alex Dickerson homered for San Francisco. Buster Posey doubled twice.
"I don't think we played our best game from any angle," Giants manager Gabe Kapler said. "We were uncharacteristically out of the strike zone a bit and I don't think we defended our positions the way we're capable of."
Polanco tripled to give the Pirates an early lead. Reynolds, one of two Pittsburgh All-Stars along with Frazier, made it 3-0 with his home run off starter Johnny Cueto in the third after Ke'Bryan Hayes' two-out single.
Cueto struck out seven and allowed three runs and three hits in five innings. The right-hander, who has 21 career wins against the Pirates and is 10-0 with a 1.78 ERA over his last 15 starts against them dating to 2012, was in line for the loss before Dickerson's tying two-run homer in the sixth.
Pirates starter Chad Kuhl matched his career-high of eight strikeouts in 5 1/3 innings. Kuhl allowed six hits and three runs with one walk.
CUETO, MAN OF STEAL
After drawing a walk off Kuhl in the second, Cueto drew loud cheers when he stole second base as Wade struck out. Cueto got a good jump and made it safely standing up. It was the first steal attempt by Cueto in his 14-year career.
"It's something I've been thinking about for a long time," Cueto said through an interpreter. "I told (first base coach Antoan Richardson), 'you've just given a green light and I'm going to steal the base,' and that's what I did."
GIANTS SIGN TOP PICK
The Giants signed their top pick in the draft, pitcher Will Bednar, who was taken 14th overall. Bednar went 9-1 with a 3.12 ERA in 19 games while helping Mississippi State to its first national title. Bednar attended Friday's game, which gave him an opportunity to catch up with his brother, David, who is a reliever with the Pirates.
Pirates: RHP Luis Ovideo (left quad strain) was activated off the injured list. Ovideo had been out since June 7. RHP Max Kranick was optioned to Triple-A Indianapolis.
Giants: Brandon Crawford did some baseball activities before the game as he works his way back from a left oblique strain. The veteran shortstop is expected to be out 10-14 days. ... 1B Brandon Belt (right knee inflammation) ran on a treadmill and will ramp up to running the bases Saturday. ... OF Jaylin Davis (left hamstring) will begin a rehab assignment with Triple-A Sacramento on Saturday. ... RHP Aaron Sanchez (bicep tighatness) threw 91 pitches in a rehab start and was headed back to San Francisco on Friday.
Giants RHP Kevin Gausman (9-3, 1.84 ERA) attempts to bonce back from his worst outing this season after lasting only three innings against the Dodgers on Monday. Pirates RHP Wil Crowe (1-5, 6.12) has allowed at least one run in the first two innings in 11 of his 13 starts this season.
Giants fans have intense kayak race over home run ball
Steven Duggar belts a solo homer into McCovey Cove, and a pair of Giants fans race to retrieve it.