CHICAGO — The Cubs have soared to the top of the major leagues with little help from Jason Heyward in his first season in Chicago.

If their $184 million man can start delivering like he did Sunday, look out.

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 San Francisco Giants 3-2 on Sunday to take three of four games in a possible playoff preview.

“It’s huge because we have a good team,” Heyward said of his recent uptick, “and when you add that to it, it just makes us that much better.”

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.

Heyward left St. Louis in the offseason for a big-money deal with the Cubs, but he was hitting. 225 when manager Joe Maddon benched him for four games last month.

“I really believe when a very good major league player may be struggling, if he just sits and watches a major league game being played and then understands, ‘I’m one of the best,” it does something internally,” Maddon said.

Heyward has five multihit games in his last eight starts.

“Just being more consistent with timing, with better swings, swinging at better pitches,” Heyward said.

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

The Cubs maintained a 16 1/2-game lead in the NL Central, while the Giants lead over the Cardinals for the first wild card was reduced to 1 1/2 games.

The Cubs were staring at a second straight loss when Russell led off the ninth with a double against Santiago Casilla. He 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.

The Giants appeared on their way to the win in regulation despite managing two hits thanks to seven innings of five-hit ball from Johnny 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.

In his first start since Aug. 14 because of a shoulder strain, Lackey allowed one earned run and one hit in five innings.

Heyward made up for 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 Hayward’s bloop single scored Anthony Rizzo in the fourth, the Giants got their first hit an inning later on Nunez’s one-out liner to the gap.

The Giants mustered 14 hits in the four games, failing to score in 16 innings against Chicago’s bullpen.

“To go against a staff like this you’d figure they were going to be low-scoring games. It’s tough to come away with three losses,” manager Bruce Bochy said. “They played well. We just didn’t do a lot of hitting.”

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.

Cubs: Setup man Hector Rondon (triceps) could come off the disabled list as soon as Monday.

RIZZO RECOVERS

Maddon pointed out Rizzo took off immediately to score on Heyward’s liner a day after a baserunning blunder in the ninth inning of a 3-2 loss.

SCARY MOMENT

Giants 1B Brandon Belt, who has had multiple concussions, stayed in after taking Rob Zastryzny’s 87 mph fastball of his helmet in the seventh.

NATHAN DEBUT

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

SIXTH MAN

Chicago will stick with a six starters through another turn in the rotation, with LHP Mike Montgomery getting the ball Wednesday at Milwaukee.

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).