The first-place Diamondbacks opened a three-game lead over the Dodgers in the NL West.
Johnson, a five-time Cy Young winner, struck out six to increase his career total to 4,723, second all-time behind Nolan Ryan. He was lifted for a pinch-hitter in the seventh, when the Diamondbacks pulled ahead with two runs against reliever Chan Ho Park (4-3).
Tony Clark tied it 1-1 with a leadoff homer to center on Park's second pitch of the game. Chris Snyder singled and advanced on Chris Burke's sacrifice bunt before Chad Tracy batted for Johnson and walked. Stephen Drew followed with an RBI double than landed just inside the right field line.
Chad Qualls and Jon Rauch each pitched a hitless inning and Brandon Lyon got three outs for his 24th save in 29 attempts.
Lyon gave up a leadoff single to Russell Martin, bringing Ramirez to the plate with a chance to pull out a dramatic victory for his new team. But Ramirez hit into the double play and Jeff Kent popped out to second.
Dodgers rookie Clayton Kershaw allowed four hits over six scoreless innings. The 20-year-old left-hander was lifted for a pinch-hitter in the sixth, when Los Angeles capitalized on a throwing error by second baseman Orlando Hudson to take a 1-0 lead.
Juan Pierre, batting for Kershaw, reached on Hudson's ninth error. Pierre stole his 37th base after Johnson had him picked off first and Clark threw the ball into left field. Matt Kemp drove in the run with a double to left, extending his career-best hitting streak to 19 games. But he strayed too far past third on Ramirez's infield single to first and was tagged out in a rundown to end the inning.
Once Ramirez got settled in with his new teammates, including former Red Sox Derek Lowe and Nomar Garciaparra, he met with manager Joe Torre and donned his white Dodger uniform shunning the trademark baggy pants in favor of a slightly more streamlined look.