NEW YORK -- Chris Flexen pitched six effective innings, rookie Dominic Smith homered and the New York Mets ended a three-game skid, beating the Arizona Diamondbacks 4-2 Wednesday night.
The Mets won for just the second time in 10 games.
Making his sixth big league start, Flexen (3-2) gave up two runs and six hits. He walked four and struck out five.
Flexen escaped a bases-loaded, one-out jam in the fifth, helped by his defense. J.D. Martinez hit a liner to shallow center field that was caught by a charging Juan Lagares, and the former Gold Glover threw a strike home to get A.J. Pollock at the plate.
The Mets led 3-2 when Smith led off the sixth by connecting against reliever Jake Barrett.
AJ Ramos worked around a two-out walk for his 23rd save in 25 chances. He has converted all three save opportunities with the Mets.
Zack Godley (5-7) pitched five innings for the wild card-contending Diamondbacks.
Martinez hit an RBI single in the first. Brandon Nimmo doubled to start the bottom half and scored on Michael Conforto's single.
Conforto singled home Nimmo again in the fifth.
Chris Iannetta closed the gap to 3-2 in the Arizona sixth with his 12th home run.
Pollock was tagged out at the plate by Mets catcher Travis d'Arnaud. In the eighth, Pollock robbed d'Arnaud of a home run by making a leaping grab at the center field wall.
Jake Lamb and Paul Goldschmidt left a total of 11 men on base out of the three and four spots in the Arizona lineup. The two All-Stars have a combined 193 RBIs this season.
Diamondbacks SS Nick Ahmed (broken right hand) felt great after playing six innings at shortstop with the rookie-level Diamondbacks on Tuesday, according to manager Torey Lovullo. The next step is for Ahmed to get some at-bats with Triple-A Reno, but the club wanted to see how he was feeling throughout the course of the day Wednesday before committing to a timetable.
Diamondbacks: LHP Robbie Ray (9-5, 3.11 ERA) will be activated from the DL to start Thursday afternoon's series finale. The first-time All-Star last pitched in the majors on July 28 in St. Louis, where he suffered a concussion after being struck in the head by a line drive.
Mets: RHP Rafael Montero (2-8, 5.47 ERA) worked six innings of one-run ball against Miami on Saturday, earning his first win since June 25.