Guerra was given a chance to earn what turned out to be the third save of his career in place of normal closer Jonathan Broxton, who has been suffering from elbow problems.
The dramatic performance in the ninth gave the win to Chad Billingsley (8-7), who blanked the Padres on four hits with five walks over eight innings.
Guerra, making the 18th appearance of his career, gave up a leadoff double to Cameron Maybin and hit both Anthony Rizzo and Rob Johnson to load the bases.
Kyle Phillips then struck out swinging on the eighth pitch of the at-bat and Will Venable struck out as well on just three pitches. That brought up Jason Bartlett, who lined out to center on a 1-2 pitch to end the game.
The only run came in the eighth when A.J. Ellis led off with a single, moved to second on a sacrifice by Jamey Carroll, went to third on a Tony Gwynn base hit and came in when Rafael Furcal singled to right.
Mat Latos (5-10) suffered the hard-luck loss, giving up five hits over 7 1/3 innings.