NEW YORK — DJ Stewart hit a tiebreaking three-run homer in the sixth inning Tuesday night, lifting the New York Mets to a 4-2 win over the Chicago Cubs.

Stewart had just three hits in his previous 23 at-bats before sending a no-doubt drive into the second deck in right field against Adbert Alzolay (1-3) to give New York a 4-1 lead.

With the arrival of designated hitter J.D. Martinez last week and the return Tuesday of right fielder Starling Marte from the bereavement list, Stewart’s roster spot could have been in jeopardy. But the Mets hung onto the left-handed batter, and he certainly delivered against the Cubs.

“It’s definitely a weight off,” Stewart said. “But this is the big leagues — you have to earn opportunities every single day. So I’m not going to take that for granted, and continue to grind (and) be ready as much as I can be whenever my name is called.”

Stewart gazed toward the home dugout before flipping his bat like a baton upon beginning his trot. The 30-year-old outfielder and DH said he was looking at manager Carlos Mendoza, who has been encouraging him to stay optimistic since spring training.

“It’s good to see DJ contribute the way he has — and for a guy that was the last guy we told he made the team,” Mendoza said. “Out of the gate, struggled, which put a little bit of pressure on himself. He’s going to give you quality at-bats and he’s going to do damage.”

Stewart hit .175 with one homer in 40 at-bats during Grapefruit League play before going hitless in his first 19 plate appearances during the regular season. Then he hit three homers in 20 plate appearances from April 8-24 — a surge reminiscent of the one Stewart mounted last season, when he had 10 homers in 17 games from Aug. 15 through Sept. 9.

“I know what I’m capable of,” Stewart said. “I really wanted to be a part of it and help this team. Obviously, J.D. makes this team way better, but I think I can do that as well in situations and in times that I get opportunities.”

All three runs against Alzolay were unearned due to a throwing error by Gold Glove shortstop Dansby Swanson. First baseman Patrick Wisdom also made a throwing error in the first, leading to Pete Alonso’s sacrifice fly.

“We got burned by not capitalizing on some outs tonight,” Chicago manager Craig Counsell said.

A fans bite dogs story: The Mets sold 44,269 frankfurters on $1 hot dog night. The announced attendance was 22,880.