Chicago took two of three in the series and has won four of its last five overall. The Cubs won a series at home for the first time this season.
Samardzija (2-5) picked up his first victory since opening day, giving up two runs on five hits with a walk. He had been 0-5 in his previous seven starts.
The home run by Samardzija was a two-run blast in the second that gave Chicago a 3-1 lead. His other homer came in 2009, which was his second season with the Cubs.
Jon Garland (3-4) absorbed the loss, giving up three runs on seven hits in five innings.
The Cubs were clinging to a one-run advantage before picking up three runs in the seventh, an inning that featured back-to-back RBI singles from Starlin Castro and Anthony Rizzo.
Couple mistakenly served bag of cash at McDonald's drive-thru
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need