Evan Longoria, whose wild throw gave Pittsburgh the go-ahead run in the top of the ninth, started the rally in the bottom half with a leadoff single against Wil Crowe (4-7).
After pinch-runner J.D. Davis was forced out at second on a grounder by Mike Yastrzemski, Estrada cleared the wall in left-center for his 11th homer and first career walk off.
“I enjoyed every minute of it,” Estrada said through an interpreter. “As soon as I made contact, I knew it was gone.”
Bryan Reynolds homered, doubled and drove in five runs for the Pirates, who lost their fourth in a row. They went 2-8 on a road trip that covered nearly 6,000 miles from Baltimore to Arizona to San Francisco.
“It’s tough going back and forth,” Reynolds said. “It’s just how it goes sometimes. It stinks that’s how it ended. It’s been a grind but we showed today what we’re made of. We’re always getting in there and fighting.”
Camilo Doval (4-5) pitched the ninth for the victory working for a third straight day.
It was 6-all in the Pirates ninth when they put runners at first and second with one out. Rodolfo Castro hit a slow roller toward third base for an infield single and Longoria's throw sailed over first baseman Wilmer Flores.
Ben Gamel tried to score from first base, too, on the overthrow and was thrown out at the plate. The Pirates challenged the call, which was upheld.
LaMonte Wade Jr. hit a three-run homer in the second to put the Giants ahead 4-0.
Reynolds had a two-run double in the fifth as Pittsburgh scored three times to close within 5-3. Reynolds, who had three hits, had a three-run homer in the seventh that put the Pirates ahead 6-5.
Brandon Crawford hit a tying double in the Giants seventh.
The Giants bullpen gave up a five-run lead after starter Alex Wood struck out a season-high nine in six strong innings.
“We won, that's all that matters,” Wood said. “Made it a little intersting, but sweet swing by Thairo. He likes those moments and that was a good time for it.”
UP THE RANKS
Giants first baseman Brandon Belt tied former INF Robby Thompson for seventh-most games (1,304) in San Francisco history. The team moved West in 1958.
Pirates: 3B Ke’Bryan Hayes missed his third straight game with back spasms.
Giants: C Joey Bart played for the first time since last Monday after dealing with a sprained right ankle. “I don’t think there’s any restriction,” manager Gabe Kapler said. “He’s ready to rock and roll.”... LF Joc Pederson left the game with a bruised right hand after being hit by a pitch in the fourth.
Pirates: Following an off day, RHP Mitch Keller (4-8, 4.25) takes the mound at home against Boston on Tuesday night to began a nine-game homestand. Keller is seeking to win back-to-back starts for the first time this season.
Giants: RHP Alex Cobb (3-6, 4.15 ERA) starts Monday’s series opener at home against Arizona, facing former Giants star Madison Bumgarner (6-11, 4.13). Cobb is seeking to snap a 12-start winless streak in which he is 0-5 since beating the Mets on May 17.
More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP_Sports