Kirk Nieuwenhuis ducked his head out of the dugout Sunday and raised his batting helmet, the personification of a team that has known the darkness as well as the light.

The outfielder had struggled so badly that earlier this season, the Mets traded him to the Angels for cash, then reacquired him when he wound up on waivers. But all was forgotten during Nieuwenhuis' moment in the sun, earned after belting his third home run in the Mets' 5-3 victory over the Diamondbacks.

"It's been a wild ride, for sure," Nieuwenhuis said. "Today was a lot of fun."

The Mets got to the All-Star break at 47-42 despite constant injuries and an offense that has habitually failed to support its stellar pitching.

Having won four straight games and seven of their last nine, they are two games behind the NL East-leading Nationals and only one game out of the wild card.

"We are very, very fortunate to be where we are," manager Terry Collins said.

advertisement | advertise on newsday

Indeed, those injuries have forced the Mets into unenviable situations, such as the one they found themselves in Sunday. That's when Collins penciled Nieuwenhuis into the fifth spot in the lineup even though he was hitting .091 with no homers.

By the end of a day he called "a little bit surreal," Nieuwenhuis found himself trying to remember if he had ever hit three homers in the same game at any level in his career.

"It was a good way to end the first half," said lefty Jonathon Niese, the beneficiary of the outburst. "There's a lot of confidence in this group. And a lot of determination and a lot of heart."

The Mets hit four homers to complete a three-game sweep of the Diamondbacks, with Daniel Murphy adding a solo shot in the third inning. They hit nine homers in the series to account for all 13 of their runs.

Niese (5-8) held the Diamondbacks to three runs and five hits in 6 2/3 innings, good enough to extend his streak of quality starts to seven. Jeurys Familia recorded his 27th save.

Mets videos

But the day belonged to Nieuwenhuis, who became the 10th Mets player in history to hit three home runs in a game and the first since Ike Davis in 2012. The list also includes Jose Reyes, Gary Carter, Darryl Strawberry and Dave Kingman. Only Nieuwenhuis accomplished the feat at home.

His first home run, a solo shot off Rubby De La Rosa in the second inning, barely rose above the leftfield fence.

In the third, Nieuwenhuis' two-run shot cleared the wall just to the left of straightaway center.

In the fifth, against reliever Randall Delgado, Nieuwenhuis watched his towering fly ball hit the screen of the rightfield foul pole. The Mets' dugout exploded, with players raising their arms as they rushed the top step for a better view.

Moments later, Nieuwenhuis made his way up those same steps for an ovation.

advertisement | advertise on newsday

"I knew what it was," he said. "I've watched enough TV."

Later, Nieuwenhuis struck out in his bid to become the first Met to homer four times in a single game. But that was a mere footnote.

After hitting 11 home runs in their previous 22 games, the Mets have 10 in their last four.

Said Collins: "To finish off the first half like this is really, really cool."