NEW YORK (AP) -- Aaron Hicks robbed Wilson Ramos of a first-inning grand slam in the outfielder's return from the disabled list, and the playoff-bound New York Yankees beat the Tampa Bay Rays 6-1 Tuesday night to clinch home-field advantage if they end up in the AL wild-card game next week.
Tampa Bay's first three batters reached against rookie Jordan Montgomery (9-7), and Hicks leaped at the 385-foot sign in right-center to get his glove above the wall. He squeezed the webbing tight, preventing the ball from popping out and limiting Ramos to a sacrifice fly.
With its 17th win in 23 games, New York (88-69) moved 19 games over .500 for the first time since finishing 95-67 in 2012. Assured no worse than a wild-card berth, the Yankees closed within three games of AL East-leading Boston with five remaining. The Red Sox lost 9-4 at home to Toronto.
Tampa Bay (76-81) was eliminated from playoff contention and missed the postseason for the fourth straight year.
Starlin Castro homered leading off a four-run second, when Blake Snell (4-7) walked a pair of batters with the bases loaded and Chaz Roe threw a run-scoring wild pitch. Gary Sanchez and Matt Holliday added RBI singles in the eighth.
Montgomery allowed singles to his first two batters and walked the next one before striking out Logan Morrison. The left-hander retired Ramos on Hicks' grab, then fanned Adeiny Hechavarria. Told his night was over after allowing one run and six hits in six innings, Montgomery walked over to Hicks in the dugout and gave him a hug.
Hicks strained his right oblique muscle June 25 on a checked swing against Texas and did not return until Aug. 10. He strained his left oblique at Boston on Sept. 2 when he reached up to make a running catch on the warning track of Hanley Ramirez's drive. Hicks walked three times, struck out in the sixth and left the game.
In the shortest of his 42 big league starts, Snell failed to retire any of his six batters in the second inning and threw only 24 of 49 pitches for strikes. He allowed four runs, four hits and four walks -- after walking Hicks on five pitches, he threw four straight balls to Aaron Judge, his final batter.
Tampa Bay was 53-49 on July 27 and one out from winning a series opener at Yankee Stadium only for second baseman Tim Beckham and Hechavarria at shortstop to both freeze and allow Sanchez's grounder to roll through the shift for a tying single. Brett Gardner hit a winning homer off rookie Andrew Kittredge leading off the 11th.
"It had direct impact, being it's the Yankees in our division," Rays manager Kevin Cash said. "There's been a handful of losses that are going to sting throughout the offseason."
New York threw its 52nd wild pitch of the season with Sanchez behind the plate.
SEAT OF THEIR PANTS
New York's David Robertson and the Rays' Austin Pruitt both threw out batters while seated on the infield grass after slipping to field eighth-inning dribblers.
IN THE MONEY
Ramos started his 55th game at catcher, triggering a rise in his salary next year from $8.5 million to $10.5 million as long as he doesn't finish the season on the disabled list because of a right knee injury. If he starts the five remaining games, his salary would rise by an additional $250,000.
Retired heavyweight champion Mike Tyson was on the field during batting practice.
Yankees: RHP Adam Warren, who hasn't pitched since Sept. 1 because of a lower back spasm, tossed a two-inning simulated game and could be activated this week.
RHP Luis Severino (13-6) starts for the Yankees on Wednesday in what will likely be his last appearance before the playoffs. RHP Matt Andriese (5-4) goes for the Rays.