The D-backs trailed, 4-2, heading into the eighth inning, when they broke through against the Mets' bullpen.
Justin Upton reached base to start the inning, thanks to an error by first baseman Ike Davis.
After a walk to Jason Kubel, reliever Tim Byrdak fanned Miguel Montero before giving way to Jon Rauch.
Goldschmidt jumped on Rauch's first pitch and laced a double to right-center field that scored both runs to tie the game at 4.
"I was just looking for something to hit, whether it was early or late in the count -- just something up a little bit," Goldschmidt said. "He threw his slider or cutter or whatever he has, and it was up and middle of the plate, and I was able to put a good swing on it."
Said Rauch, "I just left the pitch up and he put a good swing on it and hit it where we didn't have anybody, and that's on me. I've got to come in and execute pitches right off the bat, especially with guys on. I haven't done a very good job of that lately. It was a ball that probably looked as big as a beach ball coming in, and he put a real good swing on it."
Ransom followed with a single to center to score Goldschmidt with what proved to be the winning run.
"I just tried to stay through the middle," Ransom said. "I've been a little too aggressive with runners in scoring position, so I was trying to be a little more patient and get a little better pitch to hit."
With regular third baseman Ryan Roberts struggling to start the year, Ransom has gotten more playing time. The 36-year-old, who has shuffled between Triple-A and the Majors since 2001, has made the most of it, hitting .345 with three homers and 10 RBIs in 29 at-bats.
Ransom accounted for both Arizona runs in the second, when he homered off Mets starter Dillon Gee. It was the lone damage the D-backs were able to put together against the right-hander.
"It was a fastball, elevated," Ransom said. "He didn't throw too many pitches up in the zone today. I was able to get one early, but he changed speeds and kept us off-balance pretty well."
While Ransom usually posts very good numbers at the Triple-A level, he has not in the Majors -- though, in fairness, he's never gotten a prolonged opportunity to show what he could do.
"There's been times where I've had opportunities, and I come up and don't play a lot or play off the bench, and it is what it is -- it's a great job if you can do it," Ransom said. "I've been good at it at times, and I've been really bad at it at times."
There was a period in 2005 when he thought he would never get back to the big leagues.
"I wasn't really playing in Triple-A, so I thought I was done," Ransom said.
D-backs closer J.J. Putz retired the Mets in order to pick up the save. Putz got some defensive help from center fielder Gerardo Parra, who made a diving catch in left-center field to end the game.
It was the first appearance for Putz since he blew a save Wednesday night against the Nationals.
"Threw the ball good," Gibson said. "Got us out of it. That's what we're looking for. I was happy to see him just back out there I know he doesn't like what happened the other night in Washington. It was good to get him back out there and to get his sixth save."