Updated

Anthony Rizzo's two-run home run in the seventh inning helped the Chicago Cubs take a 5-4 win over the Pittsburgh Pirates in the second of a four-game set.

Pittsburgh is now a game behind St. Louis for first place in the NL Central as the Cardinals defeated the Mariners in extra innings on Friday.

Brian Bogusevic was 3-for-4 with a two-run home run for the Cubs, who had dropped their previous two. Jake Arrieta gave up four runs -- three earned -- on six hits in five-plus innings, while Carlos Villanueva (6-8) got the win for recording the final out of the sixth.

Pedro Alvarez, Russell Martin and Garrett Jones hit consecutive solo home runs in the fourth inning for the Pirates, who had a four-game winning streak snapped.

Charlie Morton went five innings in the start and gave up three runs on four hits and two walks. Jason Grilli (0-2) was handed the loss for giving up Rizzo's homer.

With two outs in the seventh, Luis Valbuena kept the inning alive with a walk and Rizzo followed with his 22nd home run of the year for a 5-4 lead.

"I think it was huge for him and hopefully it carries him for the next couple of weeks here," said Chicago manager Dale Sveum about Rizzo. "He had some real nice swings tonight so it would be nice to see that confidence build."

Justin Grimm pitched around a two-out walk in the seventh, while Pedro Strop gave up a one-out single in the eighth but escaped without damage.

Kevin Gregg allowed Jose Tabata to reach base in the ninth with an infield single and two outs, but then got Neil Walker to fly out and pick up his 32nd save.

Nate Schierholtz started the second with a walk and moved to second on Ryan Sweeney's sacrifice bunt. Bogusevic followed with a single to put runners on the corners and Darwin Barney's fielder's choice gave the Cubs a 1-0 lead.

In the fourth, Dioner Navarro led off with a single and Bogusevic made it a 3-0 game three batters later with his fifth home run of the season.

Pittsburgh, though, had three straight home runs in the bottom of the fourth to tie the game.

The first one came from Alvarez as he clubbed a pitch that went off the top of the wall in right-center and hustled all the way home for an inside-the-park homer, his 33rd of the year. The next pitch saw Martin smack it clear over the left field wall, and Jones tied the game two pitches later with a shot to center.

It was the first time the Pirates had three consecutive home runs in one inning at home since July 6, 1955 against the Brooklyn Dodgers.

"Obviously that got us going and whenever something like that happens it's a huge deal," said Alvarez. "We just couldn't turn that energy into a win tonight."

Pittsburgh took a 4-3 lead in the sixth as Andrew McCutchen doubled to start the frame and raced home when Alvarez hit a chopper to first that saw Brooks Raley miss the toss while covering the bag.

Game Notes

Pittsburgh still leads the season series, 8-6 ... The Pirates were just 1- for-6 with runners in scoring position and stranded seven ... Scott Baker pitches for Chicago on Saturday while Gerrit Cole will go for Pittsburgh.