Outfielder Xavier Paul was recalled to replace Ramirez and was in the starting lineup in left field against the D-backs.
Manager Joe Torre said that with the upcoming All-Star break, Ramirez will be eligible to return July 15 when play resumes in St. Louis, missing only 11 games. Torre said Ramirez "expressed interest" in a Minor League rehab stint before he returns.
"To me, there's no reason to gamble," Torre said. "We already had lost him for six games [estimating a Wednesday return]. For the tradeoff of having him as a pinch-hitter, I thought this was safer. When the second half starts, we won't have time to nurse him."
Ramirez, 38 years old and in the final season of a two-year contract, was injured in the first inning of Tuesday night's game in San Francisco while running the bases. He had an MRI on Thursday that showed inflammation in the lower part of his right hamstring. Earlier this year, Ramirez was disabled with a strained right calf.
Ramirez goes down just when his bat was heating up. The slugger was hitting .460 (23-for-50) with three homers and 11 RBIs over his past 15 games. He led the club in June with a .598 slugging percentage and .366 batting average. On the season, Ramirez is hitting .322 with eight home runs and 39 RBIs in 59 games.
This is the third callup for Paul, who was hitting .348 at Triple-A Albuquerque, having replaced Ramirez in April and Andre Ethier in May when he broke his finger. Torre said Paul would likely share time in left with Reed Johnson.
"We hope he gives us what he gave us last time, a little excitement," said Torre.