Samardzija (8-11) allowed two runs on seven hits, walking two and striking out seven in his second consecutive win.
Kevin Gregg picked up his 26th save as the Cubs bounced back from an 8-6 loss in Friday's three-game series opener.
Barney belted a solo homer in the fifth to open the scoring. Wil Venable answered with a bases-empty blast in the next inning to tie the score.
Chicago grabbed control in the seventh when Darnell McDonald drew a leadoff walk and, one out later, Barney socked pitch to the base of the wall in the left-field corner for the go-ahead run, chasing Padres starter Eric Stults.
After Samardzija struck out and Starlin Castro was hit by a pitch, Anthony Rizzo added an insurance run off Nick Vincent with an RBI single.
Stults (8-11) gave up three runs on six hits over 6 1/3 innings.
Venable finished 3-for-4 and Yonder Alonso added an RBI for the Padres.
Rosie O'Donnell unveils nearly 50-pound weight loss
Putin thinks Obama would save him if he were drowning