Breaking out of a six-game losing streak is a tall order when you're facing a pitcher going for his 10th consecutive victory.

To make matters worse, Marlins starter Anibal Sanchez spotted the Arizona Diamondbacks two runs in the first inning Saturday night.

The Marlins weren't able to solve Ian Kennedy, who hasn't lost a regular-season game since August, but they did prevent him from extending his streak.

They ended their own ignominious streak on Hanley Ramirez's walkoff single with two outs in the ninth inning for a 3-2 victory at Marlins Park. Ramirez was hitless in his previous 26 at-bats over seven games.

Ramirez's liner to left drove in Giancarlo Stanton, who reached on a chopper to third as a pinch hitter and advanced on Emilio Bonifacio's groundout. Diamondbacks reliever Brad Ziegler walked Jose Reyes intentionally, bringing up Ramirez.

"To see Hanley come through in that situation, that was great for us," said Reyes, who has also been slumping but drove in the first run with a single in the seventh. "Sometimes you're going to go through some tough moments, so you just continue to be strong in your mind and go from there."