Russell Martin’s eighth inning sacrifice fly scored Starling Marte to lift the Pirates to a 7-6 win Tuesday night against the Cubs at Wrigley Field.

Cubs relievers Pedro Strop and James Russell loaded the bases with three walks in the eighth, setting the scene for Martin.

It was almost the Emilio Bonifacio show, as the Cubs leadoff hitter wreaked more havoc against the Pirates by scoring the tying run in the seventh inning to cap a 3-for-4 night.

Bonifacio, now an almost unbelievable 14 for 20 against Pittsburgh this season, singled to open the seventh, moved to second on a grounder, stole third, then scored on a single by Anthony Rizzo to tie the game 6-6.

Rizzo’s single was against reliever Tony Watson, and broke his 22 1/3 scoreless inning streak that went back to last season.

Mark Melancon sat the Cubs down 1-2-3 in an efficient eighth and closer Jason Grilli did the same in the ninth.

The Pirates had 4-0 lead to open the game, and one-run leads in the fifth and sixth innings.

Charlie Morton did not have his best start, giving up five earned runs in six innings, including two homers to Starlin Castro.

In all, Morton gave up eight hits and one walk and struck out five.

Cubs starter Edwin Jackson gave up six earned runs of his own.

The Pirates got to Jackson early, taking a 4-0 lead in the first on four hits, a walk, a hit-by-pitch and sacrifice fly.