It was the second game of a three-game series relocated from Tropicana Field due to Hurricane Irma's impact on Florida's Gulf Coast.
Hechavarria, who missed hitting for a cycle by a home run on Monday in the series opener, crushed a Sonny Gray offering deep into the left field seats to give the Rays (72-74) their second win in six games. It was Hechavarria's fifth homer of the season and fourth with Tampa Bay.
Tampa Bay entered the day four games behind the Minnesota Twins in the race for the American League's second wild card.
The Yankees (78-66) had a three-game winning streak snapped. New York began Tuesday four games ahead of the Twins for the first AL wild card.
Hechavarria's homer made a winner out of Tommy Hunter (3-5), the fourth of five Rays pitchers. Alex Colome earned his major-league-leading 44th save with a perfect ninth.
Kevin Kiermaier led off the first inning with a homer for the Rays.
Matt Holliday had an RBI double in the first inning for the Yankees.
Gray (9-10) took a hard-luck loss in a complete game despite allowing just five hits and one walk while striking out nine over eight innings. He retired 12 of 13 between the first and fifth, and he set down eight straight before Hechavarria's homer.
Rays starter Blake Snell allowed one run on two hits and two walks while striking out five in five innings.
NOTES: Rays OF Steven Souza Jr. returned to the lineup after missing three games with a bruised left knee. ... Yankees 1B Greg Bird (back) missed a second straight game. The left-handed-hitting Bird, who likely would have sat regardless against Rays LHP Blake Snell, said he felt better Tuesday but underwent an MRI as a precaution. ... The 2018 Major League Baseball schedule was released Tuesday. On Opening Day, March 29, the Yankees will visit the Toronto Blue Jays and the Rays will host the Boston Red Sox. The Yankees will host the Rays in their home opener on April 2.