If this does happen to be the way Martin Brodeur’s career as a Devil ends, then at least he leaves on a high note.

On the eve of the trade deadline and with the name of the 41-year-old goalie prominent in trade talks, his Devils went out and found a way to win a game while certainly not at their best, beating the Red Wings 4-3 Tuesday night at Prudential Center.

It was no shock the fans chanted Brodeur’s name whenever possible, including after the final horn had sounded and the future Hall of Famer skated his way off the ice, his 1,250th game resulting in another notch on the all-time wins record, now at 684. And it was by virtue of a Stephen Gionta tip-in with just 36.6 seconds remaining that gave the Devils the lead and Brodeur the win.

Brodeur didn’t see a ton of action throughout the game, and as much as the weeknight fans tried to find times to chant his name, he wasn’t exactly sparkling between his own pipes.

Entering the third period down 2-1, the Devils took advantage of an early third-period power play, as Patrik Elias charged the net after Detroit goalie Jimmy Howard had gloved a soft Marek Zidlicky shot. Elias took a swipe at Howard’s pads, and then defenseman Jonathan Ericsson inadvertently had his stick sweep up and hook Howard’s glove, sending the puck up and over the goal line, tying it 2-2.

After much protest, the goal was upheld, and the Devils had momentum. Just under six minutes later, that was converted when Jaromir Jagr took a long shot and Travis Zajac corralled the rebound, firing a nifty backhand into the upper corner for the 3-2 lead.

That was quickly wiped out when the Red Wings got a power play with 10:30 remaining, and just 13 seconds into the man advantage, Johan Franzen took a shot that deflected off Todd Bertuzzi’s skate and beat Brodeur to tie it 3-3.

The Devils got down in the second period just after seven minutes in when Detroit defenseman Brendan Smith found an open space in the slot, and when Justin Abdelkader found him, Smith fired one over Brodeur’s glove for a 2-1 Red Wings advantage. Brodeur kept things close when he made a sprawling save on Bertuzzi.

Before the national anthem could begin, Brodeur was serenaded with his first “Mart-y, Mart-y” chants of the night, and his team took very little time to give him a boost. With just 27 seconds gone by, Adam Henrique skated to the net and managed to sneak one by Howard, giving the Devils a 1-0 lead and Henrique his fifth goal in the past four games, tying him with Jagr for the team lead with 19.

Yet the Red Wings soured the party after Devils captain Bryce Salvador took a boarding penalty midway through the first. On the power play, Dainius Zubrus had the puck stolen by Franzen, who made a spectacular move from behind the net, around defenseman Andy Greene, and fired the puck up over Brodeur’s right shoulder to tie it 1-1.