CHICAGO — After the San Francisco Giants dropped three out of four at Wrigley Field, Johnny Cueto was eager to face the Chicago Cubs again.

The next meeting would have to be in the postseason.

“I hope to God we do,” Cueto said through a translator. “We’re going to find out who’s got the coconuts.”

Jason Heyward tied it with a single in the ninth inning and his liner to left-center in the 13th won it as the Cubs beat the Giants 3-2 on Sunday in a possible playoff preview.

Anthony Rizzo led off the 13th with a single off Matt Reynolds (0-1) and went to second on Ben Zobrist’s groundout. Addison Russell, who had three hits, was walked intentionally before Heyward drove in his third run of the game.

“Isn’t it beautiful?” Cubs manager Joe Maddon said. “We have a nice record, but we’re coming to play every day.”

Trevor Cahill (4-4) worked a perfect inning in a series in which all four games were decided by one run.

The National League-leading Cubs were staring at a second straight loss when Russell led off the ninth with a double against Santiago Casilla. Russell went to third on a wild pitch and scored on Heyward’s single up the middle to hand Casilla his NL-high seventh blown save.

“He’s been throwing the ball well,” manager Bruce Bochy said. “It’s tough to get down on somebody who’s been doing a good job. Sure, he’s had some hiccups, but other closers are right there with him as far as saves that have gotten away.”

The Giants finished with just 14 hits in the series. Their lead over the Cardinals for the first wild card was reduced to 1 1/2 games.

“It’s fair to say we have to get some guys going,” Bochy said.

Each team had chances earlier in extra innings. Cubs closer Aroldis Chapman worked two scoreless innings, striking out Brandon Belt on a 102 mph fastball with two on to end the 11th.

The Giants’ Cory Gearrin struck out Russell looking on a questionable call with a runner on second to end the 10th.

The Giants appeared on their way to the win in regulation despite managing two hits thanks to seven strong innings from Cueto and a perfectly executed suicide squeeze.

Eduardo Nunez doubled in the fifth, stole third then broke for home as Ehire Adrianza put down a soft bunt in front of the mound that forced John Lackey to throw to first and snapped a 1-all tie.

Cueto allowed a run and struck out five.

“I was putting the pitches where I wanted to,” he said.

In his first start since Aug. 14 because of a shoulder strain, Lackey trailed 1-0 after 3 1/2 innings despite not allowing a hit.

Heyward was charged with a two-base error in the second when he couldn’t make a running catch of Hunter Pence’s fly to right-center. Pence scored the unearned run on Nunez’s groundout.

After the Cubs tied it when Heyward’s single scored Rizzo in the fourth, the Giants got their first hit an inning later on Nunez’s one-out liner to the gap.

Lackey, on a pitch count, was lifted after 76 pitches, allowed one earned run and one hit.

“That was more than I expected, honestly,” Maddon said.

TRAINER’S ROOM

Giants: Bochy didn’t start SS Brandon Crawford and LF Angel Pagan with a day game Monday at Colorado. Both ended up pinch-hitting.

SCARY MOMENT

Giants 1B Brandon Belt stayed in after taking Rob Zastryzny’s 87 mph fastball of his helmet in the seventh. Belt stayed upright as his helmet flew off, then walked to first after being looked at by the trainer. Belt said he was doing OK after undergoing concussion protocol.

NATHAN DEBUT

RHP Joe Nathan, making his first appearance with San Francisco since the 2003 playoffs, struck out Kris Bryant in a perfect 12th.

“Impressive outing. He did a great job,” Bochy said.

UP NEXT

Giants: LHP Matt Moore (9-10, 3.88 ERA) flew early to Denver and starts Monday against Rockies RHP Chad Bettis (11-7, 5.17).

Cubs: RHP Kyle Hendricks (13-7) carries the majors’ lowest ERA of 2.09 into Monday’s start at Milwaukee against RHP Zach Davies (10-6, 4.07).