It was the second consecutive wins for the Cubs, who snapped a 12-game losing streak with a win Monday over the Padres.
Samardzija (5-3) allowed eight hits and three runs in seven innings. He struck out eight and walked one. Three of the hits were by Carlos Quentin, who had a fifth-inning solo home run.
Samardzija chipped in an RBI single in the bottom of the fifth that, combined with a run-scoring double by Darwin Barney, put the Cubs up 2-1.
Alfonso Soriano hit a home run in the sixth for Chicago after he made a diving catch of a sinking liner and turned it into a double play in the top of the inning.
John Baker drove in Quentin in the San Diego seventh, but the Cubs scored on a passed ball to keep a two-run lead. Will Venable tripled in a run in the Padres' eighth only to have the Cubs counter with an RBI single by Jeff Baker.
The first four Chicago runs were charged to Eric Stults (1-1), who allowed seven hits in 6 1/3 innings.
Celebrity Breakups and divorces of 2014 [PHOTOS]