Andrew Brown also went deep for the Mets, outhomered 13-0 by Washington at Citi Field in a four-game sweep that ended Thursday.
"I think it's certainly something Lucas can feel good about right now," Mets manager Terry Collins said. "He's a big, strong guy. Everybody expects him to hit homers. I just expect him to drive runs in. And I think that swing tonight might really start him here in the last couple of weeks."
Niese (7-7) struck out seven and walked none over 6 1/3 innings, improving to 4-1 in seven starts since returning from a shoulder injury last month. New York won for the third time in 12 September games and upped its mark to 6-10 this season against the Marlins, who have the NL's worst record at 54-92.
Making his first major league start of the year, Brad Hand (0-1) gave up the go-ahead homer to Duda in the sixth and fell to 1-10 in 17 career outings.
With the Mets trailing 2-1 in the sixth before a quiet crowd of 20,562, Eric Young Jr. hit a leadoff double on an 0-2 pitch. Two outs later, Hand worked carefully to Brown and issued a walk.
On a 2-2 count, Duda pulled a hanging breaking ball to right field. Stanton raced back but the drive cleared the shortened fence.
"That's the matchup we wanted: lefty-lefty. Just need to make a good pitch and get out of that," Hand said. "I left a pitch up to him."
It was Duda's 13th home run in the majors this season -- the previous 11 were solo shots. He was recalled from the minors Aug. 24 and has been filling in at first base for injured Ike Davis, hoping to show the Mets he still belongs in their plans.
"It was just a hanging curveball and luckily I got enough of it and it got out. It was pretty windy out there," said Duda, who began the day batting .190 with four extra-base hits against lefties.
Stanton hit his 22nd home run on an 0-2 pitch leading off the seventh. That cut it to 4-3 and gave the slugger nine career multihomer games, three this season.
"We've got a few weeks left so, keep it up," Stanton said. "It really doesn't matter what I do to finish the season, I'll never get back how terrible I've been. But to turn it completely around is something I need to do, something I better do."
LaTroy Hawkins got three straight outs for his ninth save, ending a quick game that took 2 hours, 30 minutes. He struck out Stanton with a 92 mph fastball and retired Justin Ruggiano on a long fly to the warning track in right-center.
"I wanted to be in there. But that wasn't the reason I was mad," Niese said. "You set expectations for yourself and when you don't meet them, you get kind of angry. But, other than that, it was a good game and I'm glad we got the win."
Both cleanup batters homered leading off the second.
Stanton hit a screaming rocket deep into the left-center seats. Brown responded with a long drive into the second deck in left, New York's first home run since Justin Turner connected Sunday in Cleveland. The Mets allowed 14 unanswered homers during that stretch.
Consecutive doubles by Lucas and Donovan Solano put the Marlins ahead in the fifth. Miami could have scored more, but Hand bunted into an inning-ending double play with runners at the corners.
Turner (right hamstring) probably will be sidelined until at least the middle of next week. ... New York rookie Travis d'Arnaud got dinged when Lucas' backswing hit the catcher on top of his helmet in the second inning. Collins and trainer Ray Ramirez came out to check on d'Arnaud, who remained in the game. ... Mets RHP Daisuke Matsuzaka turned 33. Matsuzaka (0-3, 8.00 ERA) is slated to start against RHP Henderson Alvarez (3-4, 4.34) in the opener of Saturday's traditional doubleheader, scheduled to make up a June 7 rainout. Carlos Torres faces Miami RHP Jacob Turner in the nightcap.