The Cubs had three home runs among their 18 hits and scored five times in the fifth in what appeared would be an easy victory.
They wound up taking a four-run lead into the ninth, but Marmol gave up a solo homer to Jordany Valdespin, walked the bases loaded and gave up a two-run single to Ike Davis.
Marmol was allowed to stay in the game, however, and he faced Duda with one out and runners on first and second.
Duda's sharply hit ball on an 0-1 pitch came right back to Marmol, who then doubled Davis off first base to preserve the victory.
The score was tied at 2-2 heading into the fifth, but Anthony Rizzo hit a three-run blast for the Cubs in that frame and Jeff Baker added a solo shot. Reed Johnson hit a solo homer for the Cubs in the first.