NEW YORK (AP) Twelve minutes into Aaron Hicks' return from 3 1/2 weeks on the disabled list, Tampa Bay had loaded the bases in the first inning when Wilson Ramos drove a changeup toward the Yankees' bullpen in right-center field.

''Oh, gosh,'' New York rookie left-hander Jordan Montgomery thought to himself on the mound.

Hicks raced from center to the 385-foot sign and leaped to get his glove above the wall. He snagged the ball in the webbing, squeezed it tight and limited Ramos to a sacrifice fly with his Hollywood grab.

After nearly falling behind on a grand slam, the playoff-bound Yankees beat the Rays 6-1 Tuesday night to clinch home-field advantage if they end up in the AL wild-card game next week.

''It was fun, fun to be able to do that,'' said Hicks, who also robbed the Los Angeles Angels' Luis Valbuena of a grand slam at Anaheim on June 14.

New York closed within three games of AL East-leading Boston with five remaining. If the Yankees and Red Sox finish even, they would play a tiebreaker game in New York on Monday, forcing difficult decisions on whether to use top pitchers.

''It becomes really complicated,'' Yankees manager Joe Girardi said.

Tampa Bay (76-81) was eliminated from playoff contention and missed the postseason for the fourth straight year.

''It was kind of a slow death, which is not fun,'' manager Kevin Cash said.

Montgomery (9-7) allowed singles to his first two batters and walked the next one before striking out Logan Morrison. Ramos thought he had his second slam in five days.

''I thought he hit it pretty well, but it just kind of died for me and gave me a great opportunity,'' Hicks said.

Ramos expected the ball to carry in Yankee Stadium

''That was a homer. He jumped and he stole that,'' he said.

Montgomery then fanned Adeiny Hechavarria to end the inning and didn't allow another runner past second. Told his night was over after giving up six hits in six innings, Montgomery walked over to Hicks in the dugout and gave him a hug.

''Thanks for saving me,'' Montgomery remembered saying.

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.

He walked three times and struck out in the sixth, leaving him with a .264 average, 13 homers and 49 RBIs in 83 games. The great grab gave him confidence.

''It's definitely a big test,'' Hicks said. ''I'm fully extended and I was able to make the catch and I felt good and the body feels good right now.''

Starlin Castro hit a 445-foot home run leading off a four-run second, and New York (88-69) won for the 17th time in 23 games to move 19 games over .500 for the first time since finishing 95-67 in 2012.

Blake Snell (4-7) walked Hicks and Aaron Judge with the bases loaded in the second, and Chaz Roe threw a run-scoring wild pitch . Gary Sanchez and Matt Holliday added RBI singles in the eighth.

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.

''I just kept opening up and couldn't make the adjustment to staying closed,'' he said.

Hicks' play had changed the game.

''Incredible,'' Girardi said. ''I was worried off the bat.''

WHOOPS

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.

''I feel excited because I'm healthy and catching a lot and that's my job,'' he said.

LOOKING ON

Retired heavyweight champion Mike Tyson was on the field during batting practice.

TRAINER'S ROOM

Rays: RHP Alex Cobb won't pitch again this season because of workload.

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.

UP NEXT

RHP Luis Severino (13-6) starts for the Yankees on Wednesday in what could be his last appearance before the playoffs. RHP Matt Andriese (5-4) goes for the Rays.

---

More AP baseball: https://apnews.com/tag/MLBbaseball

Copyright 2017 by STATS. Any commercial use or distribution without the express written consent of STATS is strictly prohibited.