SAN FRANCISCO (AP) - Pablo Sandoval homered with one out in the 13th inning, sending the San Francisco Giants past the Chicago Cubs 5-4 on Tuesday night.

    

Sandoval just cleared the left-field fence with his first-pitch drive off Brad Brach (3-3) that went to replay and was upheld to formally finish the 3-hour, 45-minute game.

    

Sam Coonrod (1-0), San Francisco's fifth reliever, pitched the 13th for his first career victory. The Giants had missed a chance in the 10th when Sandoval grounded out with the bases loaded.

    

Madison Bumgarner struck out seven over seven innings in another strong start without a win to show for it, then San Francisco won playing its fifth extra-inning game in the last eight and fourth of the homestand. The Giants had a 16-inning victory Bumgarner's last time out.

    

Jason Heyward hit a tying single in the eighth for the Cubs, who have lost 10 of the last 14 in San Francisco.

    

Bumgarner, 9-2 in 14 career starts against the Cubs, dueled with Yu Darvish after the Cubs right-hander had worked six scoreless innings in each of his past two outings.

    

The Giants' recent turnaround has raised questions about whether San Francisco will try to trade Bumgarner after all if the club believes it can legitimately contend down the stretch.

    

Not that MadBum or manager Bruce Bochy has shown they're at all concerned about what's next. They just want to keep winning - and that might just take care of Bumgarner's status itself, if the Giants can play themselves back into the playoff mix.

    

"I haven't even thought about it, just like he said the same thing," Bochy said.

    

Fans certainly showed their appreciation with regular ovations again.

    

Bumgarner pitched a season-high nine innings in last Thursday's 16-inning win against the Mets.

    

"His competitive nature is the primary ingredient for me," Cubs manager Joe Maddon said. "He competes as well as any major league player competes."

    

The star left-hander's image looms large on a banner hanging high on the left-field facade outside Oracle Park, a symbol of his huge importance to the Giants for more than a decade and of course as 2014 World Series MVP. The poster reads, "It doesn't get more SF."

    

Whether that means he's still wearing his No. 40 orange and black jersey beyond next week is still to be seen - and Bumgarner also can block a trade to certain clubs if he chooses.

    

Kris Bryant hit a pair of RBI singles for the Cubs. He singled in the first as the Cubs went ahead only for San Francisco to tie it in the second on Mike Yastrzemski's sacrifice fly.

    

Bryant singled again in the third before Alex Dickerson tied it at 2 with a solo homer in the fourth. Kevin Pillar then hit a go-ahead two-run double three batters later.

    

The Giants had gone above .500 for the first time since last Aug. 14 with Monday's 5-4 comeback win (52-50) - then won for the 10th time in 11 games and 17th in 20.

    

BAKER'S VISIT

    

Former Giants manager Dusty Baker was in attendance on African-American Heritage Night. Baker hung out behind the cage during batting practice and signed posters.

    

Home run king Barry Bonds also was at the ballpark in a jersey shirt.

    

TRAINER'S ROOM

    

Cubs: LHP Cole Hamels allowed one hit over 2 1/3 scoreless innings with two strikeouts and three walks in a rehab start for Triple-A Iowa at San Antonio on Tuesday night. He has been sidelined by a strained left oblique muscle. ... C Willson Contreras (sprained right foot) will be activated from the injured list to play Wednesday afternoon's series finale, scheduled to catch lefty Jon Lester. "I'm feeling great," Contreras said. Maddon appreciates the club's depth behind the plate. "We're pretty firm there, stack that up against anybody," Maddon said.

    

Giants: 3B Evan Longoria (left foot plantar fasciitis) took groundballs and did some hitting in the cage and could soon begin doing some running and hitting on the field as he progresses. ... RHP Johnny Cueto (Tommy John surgery) will face live hitters Wednesday in Arizona. He is still considered a strong possibility to pitch in September, Bochy said. ...LF Alex Dickerson was back in the lineup after two days not starting as he nursed a tight back.

    

UP NEXT

    

Lester (9-6, 3.87 ERA) is coming off a no-decision last Friday against the Padres in which he was tagged for 12 hits, matching the most he has allowed in his career. He is 5-1 with a 2.00 ERA in six career regular-season starts against the Giants.

    

Giants starter Tyler Beede (3-3, 4.70) owns a 1.66 ERA in July. The right-hander will face the Cubs for the first time having pitched a career-high eight innings Friday against the Mets.