Arizona chased Samardzija in the sixth by putting runners at first and third with two out. Goldschmidt greeted reliever Blake Parker with a line drive home run to left field, plating three runs to make it 6-5.
"At that time you just wanted a fresh arm, but obviously that went over like a fart in a space suit," Sveum said. "We were very fortunate."
The Diamondbacks put runners on the corners with no outs in the ninth against Cubs closer Kevin Gregg. After a flyout, pinch hitter Cody Ross hit a sacrifice fly deep enough to allow Goldschmidt to score the tying run.
Gregg escaped a bases-loaded jam in the 10th, getting Prado to ground out to end the inning.
"We fought back and made a lot of mistakes and they caught up to us," Diamondbacks manager Kirk Gibson said. "We left a zillion guys on and not really swinging at good pitches in those situations ... we have no one to blame but ourselves."
NOTES: Diamondbacks C Miguel Montero sat out a second straight game due to back pain. He felt it during batting practice before Tuesday's game and was to see a doctor Wednesday. ... Diamondbacks 3B Eric Chavez has 28 RBIs in his last 31 starts after going his first five starts without driving in a run, according to the Elias Sports Bureau. ... In activating DeJesus, the Cubs optioned OF Dave Sappelt to Triple-A Iowa. DeJesus most recently played three games with Mesa of the rookie league, where he went 4 for 11 with four runs scored, two doubles and a walk. ... Samardzija and second baseman Barney collided when going for a slow roller to second off the bat of Arizona's Wil Nieves in the fourth inning. Neither was hurt.