Joaquin Benoit allowed a run in the eighth, and Jose Valverde pitched a perfect ninth for his seventh save in nine chances.
Martinez went deep in the fourth for his fourth home run of the year, giving Detroit a 2-0 lead. Miguel Cabrera drove in a run the following inning with a single his major league-leading 66th RBI.
Roberto Hernandez (3-6) allowed four runs in 5 1-3 innings.
The first-place Tigers lead Cleveland by 2 1/2 games in the AL Central. The Indians visit Detroit for a three-game series starting Friday night.
Scherzer entered the day holding opponents to a .187 average. He fanned Evan Longoria three times and kept the Rays off the scoreboard until an RBI single by James Loney in the sixth.
Martinez has struggled a bit with the bat since returning from a knee injury that caused him to miss all of 2012. But there was no doubt about his drive to right in the fourth, which cleared the wall with plenty of room to spare.
Don Kelly led off the Detroit fifth with a single, advanced to second on a groundout and eventually scored on Cabrera's bloop single to right-center.
Cabrera finished with three hits, and Prince Fielder had two to extend his hitting streak to 11 games.
Hernandez pitched 8 2-3 innings without an earned run in a win at Miami in his previous start, but he ran into trouble in the middle innings against Detroit. After Tampa Bay scored in the sixth, Hernandez allowed a leadoff double by Jhonny Peralta in the bottom half and a one-out single by Omar Infante. Pinch-hitter Avisail Garcia hit a sacrifice fly off reliever Jake McGee to make it 4-1.
Cabrera singled and stole second in the seventh and scored on a single by Martinez. Tampa Bay got a run back in the eighth on an RBI infield single by Loney.
Hernandez allowed 10 hits and a walk. He struck out six.
The Rays lost two of three to the Tigers Tampa Bay has only one series win at Comerica Park in the last nine seasons.