OAKLAND, Calif. -- After standing in the on-deck circle and watching an 11-pitch tussle between Buster Posey and Athletics reliever Blake Treinen that ended in a strikeout, Giants cleanup hitter Evan Longoria decided to take a quicker approach in his own at-bat against the former All-Star closer.
"I don't know if I swung at a first pitch this whole series but I kind of thought if this is the time, this is going to be it," Longoria said. "I figured (Treinen) was going to try and get ahead."
Longoria hit a go-ahead, two-run single off Treinen in the seventh inning after homering earlier in the game, and San Francisco rallied late again to beat Oakland 5-4 on Sunday for a two-game sweep.
Donovan Solano added four hits and an RBI for the Giants in Bruce Bochy's 4,000th game as a major league manager. Buster Posey struck out four times and grounded into a double play.
"What a great job they did here, the way they fought," Bochy said. "Another good comeback. These two games could have gone either way."
Less than 24 hours after scoring eight times in the eighth inning of a 10-5 win, the Giants fell behind early and trailed 4-3 before loading the bases against Jake Diekman (1-7) with none out in the seventh.
"I was staring at the 6-hole and really telling myself not to get around it, just see it up and get it close to me," Longoria said.
Treinen was happy with his pitch, if not the result.
"I got a groundball," he said. "I can't control where it goes."
The A's remain a half-game behind Tampa Bay for the second AL wild card.
The Giants appeared to end the game when Josh Phegley singled with two outs and was called out at second base after a throw by center fielder Kevin Pillar. Following a brief review, the call was overturned and Phegley was ruled safe. Smith then got Semien to ground out.
Earlier in the game, Longoria got his 1,000th career RBI with a solo home run off starter Brett Anderson.
"I've been thinking about it for a while," Longoria said. "It's a proud moment."
The Giants won three of four against their Bay Area rivals this season.
Neither starter factored in the decision. Anderson allowed six hits and three runs in six innings, while Webb gave up four runs and six hits in 4 2/3 innings.
Canha had an eventful day at the plate and in the field. In addition to his second career multihomer game, he made a terrific catch at the wall in center field but later made a soft throw back to the infield on a sacrifice fly in the second and let Solano's single get past him for an error in the fourth.
"We've seen him good here before when given the opportunities and the at-bats, but I don't know that he's ever been this good," A's manager Bob Melvin said.
Stephen Vogt, who hit a three-run homer as part of the Giants' eight-run eighth inning Saturday night, narrowly missed going deep again twice during the same at-bat in the sixth. Vogt hit a deep fly that curled just outside the left field foul pole, then came up short when Chad Pinder made a leaping grab at the fence.
PROFAR AT DH
Jurickson Profar had a double and two walks as the A's designated hitter. Profar, who began the season as Oakland's starting second baseman, replaced slumping slugger Khris Davis, who grounded out as a pinch-hitter in the ninth and is in a 1-for-29 funk.
HONORING `89 CHAMPS
The A's saluted their 1989 World Series championship team during a pregame ceremony. Several members including Hall of Famer Rickey Henderson and manager Tony La Russa attended the event. Dave Stewart, who won two games during the earthquake-interrupted Series against the Giants, threw out the ceremonial first pitch to his former catcher, Terry Steinbach.
Giants: Johnny Cueto will make the first of two rehab starts for Triple-A Sacramento on Monday. Cueto has already made four minor league rehab starts as he works back from Tommy John surgery. . OF Mike Yastrzemski exited with a bruised left hand.
Athletics: C Chris Hermann left with a groin contusion after getting hit below the belt by a bounced pitch. Phegley replaced Hermann. ... Stephen Piscotty is headed for the injured list because of a high ankle sprain he aggravated during an at-bat Saturday. Piscotty wore a walking boot on his right foot Sunday and did not play.
Giants: RHP Tyler Beede (3-7, 5.82 ERA) pitches against Arizona for the third time this season Monday in San Francisco.
Athletics: RHP Homer Bailey (11-8, 5.06) faces the Royals for the first time in his career Monday at Kauffman Stadium. Bailey began the season with Kansas City before being traded to Oakland on July 14.
More AP MLB:https://apnews.com/tag/MLB andhttps://twitter.com/AP-Sports
Twins pitcher Jake Odorizzi: Betting on self as 2020 free agent
Pitcher Jake Odorizzi said accepting the Twins' $17.8 million qualifying offer came down to "betting on myself and returning to a place I know very well and enjoyed."
Sources: Pirates hire Ben Cherington as new GM
The Pirates have hired Ben Cherington as the team's new general manager, according to multiple reports and confirmed by ESPN.
AL Central offseason preview: Francisco Lindor's future, Twins' rotation in focus
The Indians have a big decision to make about their biggest star, Minnesota needs a lot of arms and the White Sox could be on the cusp of good things.
Way-too-early 2020 MLB awards predictions
Will Juan Soto rise to the top? Can anyone unseat Mike Trout? Here's the first look at next year's hardware hopefuls.
Trout on 3rd MVP: 'I always try to be the best player'
Mike Trout joins SVP after winning the American League MVP award and says it was special to be recognized as the league's best player for the third time.
Bellinger: Winning MVP 'means everything'
Cody Bellinger joins SportsCenter after being announced as the National League MVP and describes how special the award is to him and his family.