D-backs starter Randy Johnson (9-7) won his fifth straight game and the 293rd of his career as he allowed just one unearned run on five hits over six innings.
A sellout crowd cheered every move by Ramirez, who wore Dodger Blue for the first time Friday, but they took it to another level when the slugger strolled to the plate to face Brandon Lyon with no outs in the ninth and a runner on first.
The situation had what Johnson called "storybook" possibilities, but it was not a fairy-tale ending for the Dodgers as Lyon got Ramirez to ground into a 6-4-3 double play and Jeff Kent to pop out to pick up his 24th save.
"It looked like Brandon had good command of the fastball away and down and made a good pitch when he had to, kept the ball on the ground and got the double play," Arizona manager Bob Melvin said.
"Brandon made some quality pitches," Johnson said. "He's done his job pretty well all year long."
Johnson has certainly done his part of late. During his five-start win streak, he has allowed just five earned runs in 32 1/3 innings and he has not allowed an earned run in his past 21 innings.
"My mechanics have fallen into place over the last three or four games so I'm able to throw all my pitches for strikes now and stay away from the big inning," said Johnson, whose slider looked particularly sharp as he got several of his six strikeouts with it.
It looked like the Big Unit would walk away from this game with a loss or at best a no-decision when the Dodgers managed to push across the game's first run in the sixth.
Matt Kemp's RBI double in the inning scored pinch-hitter Juan Pierre, who reached on an error by second baseman Orlando Hudson and advanced to second when first baseman Tony Clark misfired on a throw after Johnson had picked off Pierre.
Dodgers manager Joe Torre summoned reliever Chan Ho Park to start the seventh against Clark, who was 1-for-12 against Park in his career and had fanned the past three times he faced the right-hander.
After taking a pitch for a strike, Clark hit a low fastball over the wall in center to tie the game.
"That was huge for us," Melvin said. "They have [their bullpen] set up how they want it set up and then TC's homer kind of put a wrench in that. It started with Tony's homer definitely."
It did not end there, though, as Stephen Drew untied things with a run-scoring double down the right-field line. The ball wasn't fair by much and Drew didn't run initially out of the box, thinking that the liner was going to go foul.
Melvin then went to his bullpen, and Chad Qualls, Jon Rauch and Lyon each worked a scoreless frame to close things out.
"It was a fastball down I was simply fortunate to put a good swing on," Clark said of his game-changing homer. "That's the type of ball that very easily I could have hit a groundball to second base and not got the results I was looking for."
The D-backs have gotten what they wanted in the first two games, but just like they reacted to news the Dodgers had acquired Ramirez with a shrug they downplayed the significance of their two victories.
"We try not to get too caught up in all the hype," Melvin said. "Just try to play our game and we did it again tonight. We've got to continue to feed off the momentum we've got going right now. It's been a great trip and a great first two games for us and we look to continue on it."