SAN FRANCISCO — Wilmer Flores drew a bases loaded walk in the ninth, capping a wild comeback as the San Francisco Giants snapped a five-game skid with a 5-4 victory over the Chicago Cubs on Monday night.

Matt Chapman homered and started the rally with a bloop double off Colten Brewer.

Flores was the eighth Giants player to bat in the ninth. His walk scored Patrick Bailey, who singled with one on and one out in a 4-3 game to score Chapman, and Austin Slater’s sacrifice fly two batters later tied the game.

“We all got to wear No. 24, and that’s pretty cool,” Giants manager Bob Melvin said, acknowledging the win was especially meaningful on a night when the team held a tribute for franchise legend Willie Mays before the game.

“All the stuff pregame, it certainly gets your attention, and we’ve been thinking about this all week and finally win a game for him,” Melvin said. “Whether it was Rickwood or whatever, we had trouble winning games during his tributes, so it was good to be able to do it at home here.”

Reliever Drew Smyly (2-4) took the loss.

Giants reliever Spencer Howard (1-1) struck out eight and walked one in 4 2/3 scoreless innings of four-hit ball.

Dansby Swanson’s RBI double highlighted a three-run fifth inning in which Chicago opened up a 4-0 lead.

Chapman homered leading off the fifth (his ninth) and Ahmed leading off the sixth (his first).

Cubs starter Justin Steele, who was seeking to end a streak of 14 straight winless starts going back to last season, struck out nine and walked one in 7 1/3 innings of six-hit ball in which he gave up two runs.

Smyly got the last two outs for his first save in two attempts after Chapman scored on Michael Conforto’s sacrifice fly off Brewer.

“There’s no question we left runs on the bases for sure, and that plays into it as well,” Cubs manager Craig Counsell said.

“We could have had five, six, seven on the board by just moving the ball forward and we didn’t do it and we’ve got to do better at that. That was a game that we should’ve broken open and that cost us. It doesn’t cost you every game but it certainly cost you tonight.”

TRAINER’S ROOM

Cubs: RHP Yency Almonte (right shoulder strain) experienced symptoms while throwing live batting practice on Tuesday, manager Craig Counsell said.

Giants: LHP Robbie Ray (torn flexor tendon) will make his second rehab appearance on Friday, this time for Class A San Jose. The 2021 American League Cy Young Award winner pitched 2 1/3 scoreless innings for Triple-A Sacramento on Sunday. … LHP Blake Snell (groin) in his rehab start for Sacramento on Sunday gave up two runs in 1 2/3 innings. The reigning NL Cy Young Award winner is scheduled to throw a bullpen session Tuesday and then start for Sacramento on Friday. … LHP Raymond Burgos was selected from Triple-A Sacrament. … IF Trenton Brooks was designated for assignment.

UP NEXT

Cubs RHP Kyle Hendricks (1-4, 7.46 ERA) snapped a four-game skid in his last start, striking out eight in 5 2/3 innings of two-hit ball in a 6-5 win against the Giants on Wednesday. The Giants have not yet announced a starter for Tuesday’s game.

__

AP MLB: https://apnews.com/hub/mlb

More MLB news

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME ONLINE