NEW YORK (AP) — Mariano Rivera put his head on Andy Pettitte’s right shoulder and sobbed. The end had arrived, at least for his career in the New York Yankees’ home pinstripes.

Baseball’s most acclaimed relief pitcher made an emotional exit in his final appearance at Yankee Stadium when Derek Jeter and Pettitte came from the dugout to remove him with two outs in the ninth inning of a 4-0 loss to Tampa Bay on Thursday night.

Rivera bawled during four minutes of a thunderous ovation from the sellout crowd 48,675.

“It’s time to go,” Jeter appeared to tell his old pal when he arrived at the mound.

Pettitte, who also is retiring when the season ends Sunday, gave Rivera a 30-second bear hug. Jeter followed with a 15-second embrace.

“I was bombarded with emotions and feeling that I couldn’t describe,” Rivera said after the game, flanked by his wife and three sons. “Everything hit at that time. I knew that was the last time. Period. I never felt like that before.”

It was one of those special Yankees scenes that will join Lou Gehrig’s farewell speech, Babe Ruth’s last ballpark appearance, Mickey Mantle Day, the first game after Thurman Munson’s death and the finale at the old stadium across 161st Street as moments to cherish and remember.

There was hardly a dry eye. The Yankees and Rays stood in tribute while fans blinked back tears, honoring the closer who turns 44 in November.

His voice cracking after the game, Yankees manager Joe Girardi said he conceived the idea in the eighth inning of including Jeter and Pettitte.

“I’ve never seen a player pull another player, so I had to ask. And then one of them was on the DL,” he said.

“Then I said, ‘Well, can I send two?’ and they said, ‘Well, go ahead.’ And I really appreciate that because I think it made the moment even more special for Mo,” Girardi explained.

At first, Pettitte didn’t think it was such a good idea. When he got to the mound, he quickly decided “it was awfully cool.” The three players have known each other since they were in the minors in the early 1990s, and all three came up to the Yankees for the first time in 1995.

“It’s crazy how fast it went by,” Pettitte said.

Rivera’s demeanor caught Pettitte by surprise.

“I didn’t say anything at first, and I didn’t expect for him to be quite so emotional,” Pettitte said. “He broke down and just gave me a bear hug and I just bear-hugged him back. He was really crying. He was weeping, and I could feel him crying on me.”

Rivera had retired Delmon Young, Sam Fuld, Jose Lobaton and Yunel Escobar on 13 pitches — the overall 465th perfect outing of his big league career. He had gone to the trainer’s room in the Yankees clubhouse after the top of the eighth instead of remaining in the dugout.

“Everything started hitting from there. All the flashbacks from the minor leagues to the big leagues, all the way to this moment,” he said.

When he walked off the mound for the final time with two outs in the top of the ninth, he wiped his eyes with both arms and blew a kiss to the first row behind the Yankees dugout. He hugged a tearful Girardi in the dugout, grabbed a towel to dab his own tears, came out again and doffed his cap to the crowd. All the while, the Rays remained in their dugout applauding.

Throughout the stands, fans blinked back their own tears.

And after Rivera came off, Pettitte came out for his own curtain call before the bottom of the ninth as the Rays waited in their dugout, not wanting to interrupt the moment. Rays manager Joe Maddon is a longtime fan of Rivera’s consistency, durability and quiet humility.

“They know how to do things here,” he said. “They’re great at pomp and circumstance in this place.”

After the last out, Rivera remained on the bench for a moment as Frank Sinatra’s recording of “New York, New York” played. He paused before taking a last walk to the mound, a man alone, rubbing his feet on the rubber, kneeling and gathering a bit of his workplace as a keepsake.

“I wanted to get some dirt, just stay there for the last time, knowing that I ain’t going to be there no more,” he said.

Rivera had entered with one out and two on in the eighth to a recorded introduction by Bob Sheppard, the longtime Yankees public address announcer who died three years ago.

Fans stood and chanted his name as he jogged in from the bullpen to Metallica’s “Enter Sandman.” Rivera was making his first appearance since the Yankees retired his No. 42 during a 50-minute ceremony Sunday. Eliminated from playoff contention, New York finishes the season with three games in Houston.

He’ll always remember the home finale, along with the five World Series titles.

“It was amazing. A great, great night,” he said and then paused. “We lost. I don’t know how I’d be saying that.”