The New York Yankees mixed and matched against Tampa Bay -- at the plate and on the mound -- and emerged with a 6-4 win Sunday that kept them ahead in the AL East and ended a most damaging road trip for the Rays.

"We have a day off. Guys are going to rest tomorrow," manager Joe Girardi said. "It's their last one of the year and they'd better rest because we still have a grind left."

Martin's three-run shot highlighted an eventful early burst as New York won with small ball and a longball.

The Yankees took the last two in the three-game series, and have 16 left to play. They began the day with a one-game division lead over Baltimore, which was at Oakland.

On Tuesday night, they host Toronto. Andy Pettitte rejoins the rotation for the first time since a batted ball broke his left leg in late June.

Minus ejected manager Joe Maddon, the Rays fell five games behind the Yankees and trail the Orioles and Los Angeles Angels in the wild-card scramble. Cleanup man Matt Joyce also was tossed as Tampa Bay finished 1-5 on its visit to Yankee Stadium and Camden Yards.

"The math isn't in our favor," Maddon said.

Then again, Tampa Ray pulled off an incredible rally last season to earn a playoff spot on the final day. This year, an extra slot is available.

"The baseball gods have created two wild cards, so let's see what happens," he said.

Ben Zobrist homered and doubled for Tampa Bay. Down 6-1, the Rays scored three times in the sixth inning and later brought the potential go-ahead run to the plate, but couldn't break through against the back end of the Yankees' bullpen.

Hiroki Kuroda (14-10) set a career high for wins, struck out 10 in six innings and beat Tampa Bay for the second time this month. Rafael Soriano, the Yankees' fifth pitcher, earned his 40th save in 43 chances.

Matt Moore (10-11) lost his fourth straight start. The rookie and Kuroda started out well in the last scheduled game between the teams, with the first nine outs overall on strikeouts. Each team finished with only five hits.

Martin's opposite-field shot to right field came during a crazy five-run third. The inning included an errant pickoff throw, a wild pitch, three walks, a pair of steals, Swisher's first sacrifice bunt of the season, warnings to both benches and Maddon's ejection.

Derek Jeter put the Yankees ahead with an RBI single, moments after playfully pointing his bat toward a young fan who was taking his picture while he was on deck, Swisher bunted and Alex Rodriguez clapped his hands after singling through the drawn-in infield for a 2-0 lead.

"Yeah, I take full credit for it," said Swisher, who had one sacrifice last year.

"In a situation right there, I felt like it needed to be done," he said. "I tried to lay it down right there, and the next thing you know, Rod comes up there - ribbie."

Martin made it 5-0 with his 17th homer. Two batters later, Moore threw a 95 mph fastball behind the helmet of Curtis Granderson and plate umpire Paul Emmel immediately warned each side against any trouble.

Maddon jawed from the dugout, got tossed and came out for a protracted discussion with Emmel. Granderson crouched outside the batter's box during the dispute, watching the antics.

"That third inning was just atrocious," Moore said.

The wild inning seemed to wreak havoc with the scoreboard, too. As the Rays hit in the fourth, the score on the main board changed from 5-0 to 4-0 to 2-0 to 0-0, Kuroda's pitch count went in reverse and innings were wiped off.

Nunez stole twice to set up Rodriguez's sacrifice fly in the fourth for a 6-1 lead. Robinson Cano followed with a routine fly that left fielder Desmond Jennings lost in the sun for an error.

The Rays rallied in the sixth, helped by a couple of lucky bounces.

Zobrist walked after his foul pop fell out of fill-in first baseman Steve Pearce's glove at the railing, then Evan Longoria's possible double-play grounder took a bad hop over Rodriguez's shoulder at third base for a two-run single.

Notes

Rays RF Sam Fuld exited with a mild right hamstring strain after grounding out to end the fifth. 2B Cano bobbled the ball, recovered and threw out Fuld, who grabbed the back of his leg after crossing the bag.

Maddon has been ejected four times this year and 27 times as Tampa Bay's manager. Bench coach Dave Martinez ran the team with Maddon gone. Martinez recently interviewed for the job as Houston's manager.

Jeter has a 12-game hitting streak. He leads the majors with 199 hits.

B.J. Upton of the Rays struck out all four times up.

Rodriguez stole his 12th base in 13 tries this year. ... The Rays won the season series 10-8.