Detroit Tigers’ Victor Martinez shines against New York Yankees as he comes down stretch toward retirement

The Detroit Tigers' Niko Goodrum gestures after hitting a home run against the Yankees in the ninth inning Thursday at Yankee Stadium in New York. (AP photo)

NEW YORK — Victor Martinez is savoring the final weeks of his major league career — and showing he still has life in his bat.

Martinez tied the game with a two-run homer in the ninth inning and Niko Goodrum followed with a homer off Dellin Betances to rally the Tigers past the New York Yankees 8-7.

The homer was the second of the game for Martinez and gave him 533 RBIs with the Tigers, the most in franchise history for a switch-hitter. Martinez’s first homer was a two-run shot in the fifth.

The homers were the first since July 27 for the 39-year-old Martinez, who said he expects to retire after this season. He is batting .250 with eight homers and 47 RBIs, far off the norms he established in making five All-Star teams.

“It’s always great when you do something to help the team win, that’s the bottom line,” Martinez said.

Goodrum’s homer off Dellin Betances (4-4) capped a wild game that featured eight homers — including the 300th career round-tripper for Yankees slugger Giancarlo Stanton — as well as five lead changes and two ties.