MIAMI (AP) -- Jordany Valdespin's home-run trot was more like a sprint, and he dashed all the way to the dugout, as though he couldn't wait to trade high-fives with his New York Mets teammates.
The Mets finally had some big hits to celebrate Wednesday, when they broke a six-game losing streak and averted a series sweep by beating the Miami Marlins 7-6.
Valdespin put New York ahead to stay in the sixth inning with a three-run, pinch-homer.
"That was a momentum changer," Mets catcher John Buck said.
Buck and David Wright each had three of New York's 13 hits. NL RBIs leader Buck hit a two-run double, and Wright contributed his third homer for the Mets, who totaled only 11 runs during their losing streak.
"We got some offense going," manager Terry Collins said. "The most frustrating thing about the past six days is we've been in the games. We've given ourselves a chance, we just haven't been able to create any offense. Hopefully today is a start."
The dormant attack finally came alive after the Mets fell behind 4-1. Valdespin's second homer of the year was his sixth pinch-homer since breaking into the majors in 2012, which ties him for second place on the team's career list.
"For some reason he loves to come off the bench when the pressure's on," Collins said. "It's amazing what he has done as a pinch-hitter. His eyes seem to get bigger, and he seems to see the ball better."
Wright homered in the fourth, scored three times and made a barehanded grab and throw at third base in the seventh inning to keep a runner stranded at third. Afterward he was wrapped from neck to torso because of various maladies, including a stiff neck, but said he had been eager to play Wednesday.
"We need all the wins we can get, especially with the way we've been playing," Wright said. "You want to be in there and help out."
Miami came from behind in the final inning to win the first two games of the series, but this time the New York bullpen -- ranked next to last in the majors in ERA -- protected a lead. Bobby Parnell pitched a perfect ninth for his third save in five chances.
Dillon Gee (2-4) won despite allowing four runs and nine hits in five innings. The Mets had scored a total of 10 runs in his previous five starts.
Marcell Ozuna, who made his big league debut Tuesday, had two of Miami's 13 hits. Wade LeBlanc gave up four runs in 5 2-3 innings, and the Marlins fell to 0-6 in his starts.
"It's frustrating getting spotted three runs and letting the other team kind of creep back in," LeBlanc said.
The Mets' comeback in the sixth began when Wright led off with a double. He scored on a two-out single by Marlon Byrd, and Ike Davis also singled.
Valdespin greeted reliever A.J. Ramos (0-1) with a homer to put New York ahead 5-4.
"He has mastered the art of pinch-hitting," Wright said. "I pinch-hit a few times in my career, and he makes it look a lot easier than it is. It's impressive to watch."
Daniel Murphy and Wright singled in the seventh, and Buck followed with a double, giving him 27 RBIs. That includes eight in five games this year against his former team.
Miami's relievers gave up three runs in four innings.
"Our bullpen has been great all year, and every once in a while this is going to happen," manager Mike Redmond said.
Mets center fielder Juan Lagares threw out Nick Green trying to score from second on LeBlanc's one-out single in the fourth. LeBlanc took second on the play and came home on a single by Juan Pierre, sliding hard into catcher Buck's left knee to beat Lagares' throw.
LeBlanc was shaken up, but after a visit with the trainer he stayed in the game.
An error by left fielder Lucas Duda led to two unearned runs for Miami in the seventh. With two on, Justin Ruggiano's one-hop single skipped off Duda's glove and rolled to the wall, allowing both runners to score, cutting New York's lead to 7-6.
The Marlins matched their best first inning of the season to take a 3-0 lead. After Gee gave up two walks, Ruggiano singled home a run. With two out, Chris Valaika hit a two-run double.
NOTES: Wright improved to 8 for 13 (.615) with two homers against LeBlanc. ... On Thursday the Marlins begin their longest trip of the season, with 10 games in three cities. ... Attendance for the 12:40 p.m. start was 16,188, including several school groups.