NEW YORK (AP) -- The Mets have had a topsy-turvy season, and nobody has better represented that than streaky slugger Todd Frazier.
Frazier is back on a roll, and so is New York. Frazier and Jeff McNeil each homered twice, helping the surging Mets tag Diamondbacks ace Robbie Ray and beat Arizona 9-0.
"He doesn't let things affect him, he cares about winning first and foremost," Mets manager Mickey Callaway said. "He's a pro's pro and he's one of our leaders. And when he's going good, we are a really, really good team."
The Mets (75-70) have won the first three games of the pivotal four-game series to move past the Diamondbacks (75-71) in the race for the second NL wild card. New York is tied with Philadelphia, two games behind the Chicago Cubs and Milwaukee for that spot.
Arizona has lost four straight since going 11-1 to rush back into the crowded NL playoff picture, and is 2 ½ games in back of the second wild-card spot.
The winning streak is just the latest twist in a rollercoaster season for New York, which entered the All-Star break tied for the second-worst record in the NL but roared back into contention by going 15-1 from July 25 through Aug 10.
No player has gone through more peaks and valleys than Frazier, who didn't make his season debut until April 22 due to a left oblique injury and whose slumps endangered his playing time.
The 33-year-old is heating back up at just the right time.
"That's kind of the makeup of our team," Callaway said. "And usually, your team takes on the makeup of their leaders. And he's one of our leaders."
Frazier had two doubles and three RBIs in a 3-1 win Tuesday night and followed it with his second multihomer game of the season.
His two-run homer helped fuel a five-run first inning against starter Robbie Ray (12-8). In the third, Frazier reached the 20-homer mark for the fourth time with a solo shot.
"When I was younger, I kind of leaned on the guys that have been there before," Frazier said. "When the lows get real low, what are you supposed to do? Hit more? Hit less? It's trying to find that happy medium."
Ramos (groundout) and J.D. Davis (single) had two-out RBIs in the first before Frazier and Brandon Nimmo homered on consecutive pitches. Juan Lagares doubled to end the night for Ray, who had a blister on his left middle finger open up during his bullpen. Ray was pulled from his previous start Saturday due to a blister.
"The protective layer of skin tore off and just created a different dynamic and a different feel for him," Diamondbacks manager Torey Lovullo said. "He tried to gut it out and you could see he just didn't have the finish on certain pitches. And they took advantage of that."
Lovullo said he was confident Ray would not miss a turn in the rotation.
"Shortest outing of my career," Ray said. "It's definitely weird."
Jeff McNeil also hit two homers -- a solo shot in the second and a two-run drive in the sixth -- to join Frazier in the Mets' 20-homer club, which numbers a record-tying four. Pete Alonso leads the majors with 47, and Michael Conforto has 29. New York previously had four players hit 20 homers in 1987, 2000 and 2016.
Steven Matz (10-8) allowed four hits and three walks while striking out seven over six innings. He issued all three walks to open the second before striking Carson Kelly and inducing a double play grounder from pinch-hitter Kevin Cron.
"That kind of deflated us," Lovullo said. "We just couldn't execute and get it done."
Alonso coordinated the purchase and production of custom 9/11 cleats for Mets players on the 18th anniversary of the terrorist attacks. The shoes were painted red, white and blue and included "We will never forget" and lettering for first responder units. After winning the All-Star Home Run Derby in July, Alonso donated $50,000 of his $1 million prize to the Tunnels to Towers Foundation.
The clubs also wore first responder hats during batting practice, then lined up on their respective baselines alongside firefighters, police and EMTs prior to the national anthem.
Prior to first pitch, children who lost parents or grandparents to 9/11-related illnesses ran to each position before being joined by the Mets' starters. Alonso gave baseballs to the two children at first base while Amed Rosario went to one knee at shortstop to talk to the children there.
The Mets ended the game with nine runs on 11 hits.
Diamondbacks: RHP Luke Weaver (right flexor strain) is scheduled to throw 35 pitches or two innings for Class A Visalia in a playoff game Friday. Weaver hasn't pitched for Arizona since May 26.
Mets: RHP Robert Gsellman (lat) played long toss Wednesday and holds out hope he can return this season.
Diamondbacks: LHP Alex Young (7-3, 3.38 ERA) is coming off the best start of his rookie season when he gave up two hits and struck out 12 over eight innings in a 2-0 win over the Cincinnati Reds.
Mets: RHP Marcus Stroman (7-13, 3.42 ERA) has recorded just one quality start in seven tries for the Mets, who acquired him from Toronto on July 28.
Enjoy all things sports?
Don't miss a story! Sign up for daily stories delivered to your inbox.