Matt Kemp also went deep and Carlos Triunfel hit his first major league home run after replacing Ramirez. Greinke (9-3) threw a season-high 117 pitches over six innings, allowing a run and three hits with five strikeouts and two walks.
"It was definitely a tough game," said Greinke, who tied St. Louis' Adam Wainwright and Cincinnati's Alfredo Simon for the NL lead in wins. "It seemed like they had guys on base every inning. There were a lot of foul balls on two-strike counts where they just kept fighting it off. So it gets really tough."
Ramirez, a three-time All-Star shortstop and the 2009 NL batting champion, left in the seventh with a bruised ring finger on his right hand after Corey Dickerson's hard grounder to him deflected into short center field for an RBI double that trimmed the Dodgers' lead to 3-2.
"That was a rocket -- kind of an in-between hop to Hanley," said Rockies manager Walt Weiss, who played 1,397 games at shortstop in the majors and 37 of them at Dodger Stadium. "There's not much you can do there as a shortstop. You hope that you can smother it if it falls at your feet, but that ball was hit so hard, there's not a lot that Hanley could do on that one."
X-rays on Ramirez's throwing hand were negative.
"That's great news for us. We obviously dodged a big bullet," catcher A.J. Ellis said. "Hanley's probably the biggest part of our lineup when we're going right. He carried us last year, and I feel like he's getting close to that point where he can carry us again. He's definitely one of the best bats in all of baseball, and we'll be happy to get him back whenever he's ready."
Triunfel provided an insurance run against Tommy Kahnle with a towering drive that landed in the lower seats in the left-field corner. Brian Wilson pitched a scoreless eighth and Kenley Jansen got three outs for his 20th save, the third straight season that the former catcher has reached that figure.
Chacin (1-5) gave up three runs, seven hits and three walks in six innings. The right-hander escaped a bases-loaded jam in the sixth when he retired pinch-hitter Justin Turner on a popup.
"I knew he didn't want to come out of that game. I just went out there to check with him and make sure he was OK," Weiss said. "I wanted to let him try to get through that inning because he battled all night, so I felt he earned that. He stepped up and pitched his way through that inning."
Eleven members of the Los Angeles Kings escorted the Stanley Cup to Dodger Stadium for a pregame ceremony, four days after they won their second NHL championship in three years. The Dodgers posed with them for a group photo, then showed off their own "power play" as Ramirez hit a two-run homer in the third and Kemp led off the fourth with his seventh of the season.
Greinke also received some defensive help. Rookie third baseman Miguel Rojas robbed Dickerson in the third with a skidding, backhanded stop down the line. Right fielder Yasiel Puig took away a potential bloop single from Rosario in the fourth with a diving grab after a long run.
Greinke got through the first unscathed after giving up one-out singles by Dickerson and Troy Tulowitzki. The Rockies loaded the bases with none out in the sixth, but all they got off Greinke was a sacrifice fly from Rosario.
"Zack competed. They really battled him hard and he really grinded through some tough innings," Ellis said. "That was huge for us. That inning could have spiraled out of control and really depleted our bullpen."
Conn Smythe Trophy winner Justin Williams and his now clean-shaven Kings teammates took batting practice, fielded grounders and shagged flies. Each player threw a ceremonial first pitch simultaneously to a corresponding Dodger. After that, Kings defenseman Willie Mitchell carried the Cup over to the Rockies' dugout, where he posed with Canadian-born 1B Justin Morneau. ... Rockies RHP Nick Masset began serving the three-game suspension he received from Major League Baseball on Tuesday for throwing at Atlanta catcher Evan Gattis last Thursday. Masset also was fined an undisclosed amount. ... The Dodgers signed their first-round draft pick, RHP Grant Holmes, the 22nd overall selection out of Conway High School in South Carolina. He got a $2.5 million signing bonus. ... Chacin was coming off a 10-3 victory against Atlanta in which he held the Braves to two hits over seven scoreless innings. ... Ramirez came in 0 for 9 against Chacin, who had allowed four homers in 45 2/3 innings over his eight previous starts this season.