MIAMI (AP) -- Hanley Ramirez found the perfect opportunity to break out of a long slump.
Ramirez hit a run-scoring single with two outs in the ninth to lift the Marlins over the Arizona Diamondbacks 3-2 Saturday night, snapping Miami's losing streak at six games.
The hit ended an 0-for-26 drought for Ramirez.
"It's all about the win," Ramirez said. "We needed that one right there. Now we can have our confidence back."
Ramirez's line drive to left off reliever Brad Ziegler scored Giancarlo Stanton after he reached on a one-out infield single and advanced to second on Emilio Bonifacio 's grounder to first. Ziegler (0-1) intentionally walked Jose Reyes to face Ramirez.
An excited Ramirez jumped as he reached first base and slammed his helmet to the ground.
"It pumped me up," Ramirez said of being pitched to instead of Reyes. "I knew what they were trying to do but at the same time I told myself, `Shorten your swing down and stay through the middle."'
Arizona manager Kirk Gibson defended the decision to walk Reyes.
"I felt that Reyes is a slap (hitter) who can run," Gibson said. "It gave us a forceout at any base as well. Ziegler didn't get the pitch where we wanted to. It didn't work out for us."
Steve Cishek (2-0) earned the win with a perfect ninth for Miami, which got a 14-strikeout performance out of starter Anibal Sanchez .
"This game was big for us and the way we won it," Miami manager Ozzie Guillen said. "It was big for the players. It brought their emotion back. Games like that can get you going."
Logan Morrison hit a leadoff homer in the eighth to tie it 2-2, driving Arizona reliever David Hernandez 's pitch over the right-field fence for his second home run of the season.
The Marlins broke out of an 18-inning scoreless drought on Reyes' RBI single in the bottom of the seventh. Reyes drove in pinch-hitter Omar Infante , who reached on a leadoff triple to deep center.
Arizona starter Ian Kennedy left after surrendering Reyes' single. Kennedy pitched 6 1-3 innings, allowed one run and seven hits, walked two and struck out five.
"It was a battle trying to throw strikes," Kennedy said. "I don't know. I wasn't very efficient pitches-wise. I think halfway through I looked up and I had about 50-50 balls and strikes."
The Diamondbacks struck quickly on Gerardo Parra 's first-inning RBI double. Miguel Montero 's run-scoring single drove in Parra for a 2-0 Arizona lead. Arizona loaded the bases with two out but Sanchez avoided additional trouble as he struck out Ryan Roberts to end the inning.
Sanchez settled down after the difficult first inning and retired the final 18 consecutive hitters he faced. Sanchez allowed three hits, walked four and his strikeout total was a career best.
"I made the adjustments right away," Sanchez said. "I threw the ball down and kept it in the zone. I tried to keep the score like that and wait for the hitters to wake up a little bit to tie the game or go ahead.
Justin Upton 's one-out walk in the eighth gave Arizona its first baserunner since Sanchez walked Willie Bloomquist with two out in the second.
Miami wasted early scoring opportunities against Kennedy. Sanchez and Emilio Bonifacio singled to start the third and advanced on Reyes' sacrifice bunt. Ramirez popped out to third on Kennedy's first pitch and Gaby Sanchez struck out with the bases loaded after Morrison had reached on a hit-by-pitch.
In the fourth, Greg Dobbs reached on a leadoff triple but failed to score as Kennedy struck out Brett Hayes and Chris Coghlan and retired Sanchez on a soft line drive to shortstop.
"Those runs we left early in the game, we have to be better than that," Guillen said. "We don't have the luxury to leave those guys out there. At the end you're going to need those runs."
Notes: The Marlins did not take infield practice before the game. Parts of the infield were still moist from overnight rain that skirted off the infield tarp. The roof which covers Marlins Park was left partially open to irrigate the outfield grass. ... Sanchez's previous career strikeout high was 11 against Pittsburgh on Sept, 10, 2011. ... Third base umpire Mike DiMuro left the game because of back pains after the top half of the first inning and was replaced by Mike Estabrook. Jason Kubel went 0-for-4, ending a 10-game hitting streak... LHP Patrick Corbin will be called up from Double A Mobile and will start Arizona's series finale against Miami Monday afternoon. Corbin is 2-0 with a 1.67 in his two minor league starts. The Diamondbacks will announce the corresponding move on Sunday.