The All-Star third baseman was scheduled to start Monday night's series finale at Yankee Stadium and bat third.
"He came in. He was adamant. He felt ready to go today, so we threw him out there," Rays manager Joe Maddon said.
Since injuring the leg while running out a grounder last Tuesday, Longoria had been limited to a pair of pinch-hitting appearances against the Yankees. He is hitting .322 with 13 homers and 55 RBIs in 52 games, and he leads the AL in voting for this year's All-Star Game.
"It just makes a huge difference. I know he's eager to get back out there. It's difficult for him to sit around, too," Maddon said. "It's very difficult to watch him sit around."
Willy Aybar, who had been down to play second base in the original lineup, was scratched about 40 minutes before the first pitch because of a migraine. Ben Zobrist moved from shortstop to second, and Reid Brignac took over at shortstop.