Alex Rodriguez experienced a little of the “magic” at the plate that Joe Girardi had said he wished for him in his last game as a Yankee. And the manager took care of the rest in the top of the ninth inning.

With the Yankees leading the Rays by three runs, Girardi sent Rodriguez out to third base Friday night, accompanied by raucous cheers from the sellout crowd of 46,459 at the Stadium.

Rodriguez, who laced an RBI double off Chris Archer in the first inning, stayed in for one batter, Mikie Mahtook, whom Dellin Betances struck out.

Girardi then sent in Ronald Torreyes for A-Rod, who received another loud ovation as he walked off the field, hugging teammates as he went.

“Just overwhelmed,” A-Rod said after the Yankees’ 6-3 win.

advertisement | advertise on newsday

Girardi, who broke down a couple of times during his postgame news conference while discussing Rodriguez’s final game, said he was happy to give the DH something he had wanted, which was to play third base, if only for a batter. “If this is the last time he plays,” Girardi said, “I wanted it to be something he never forgot.”

While not ruling out playing again, A-Rod did sound as sure about his future as he has since last Sunday, when it was announced that Friday night would be his final game in pinstripes. “It’s going to be tough to top this,” he said. “This is the only job I’ve had for 22 years. With all the things I’ve been through and to have an ending like tonight, I don’t know what else a man can ask for.”

After the game, A-Rod, again surrounded by cheers, walked to third base, scooped up some dirt and put it in his back pocket.

“I hope this was as good as it could get for him,” said Girardi, who added that had it been a two-run lead instead of three, he would not have put Rodriguez in at third. Aaron Hicks’ opposite-field homer to left in the seventh gave him the cushion he needed.

This being A-Rod, the night did not come without some awkwardness.

Yankees videos

It started with an almost apocalyptic thunderstorm that brought everything but frogs, dousing a pregame ceremony in A-Rod’s honor, then dissipating almost as quickly as it arrived.

“It certainly was like Biblical,” said Rodriguez, who was given a signed base and framed jersey by managing general partner Hal Steinbrenner, who coordinated much of the last week, during the ceremony. “At one point I said, ‘Hal, we have to take it in.’ He said, ‘Let’s go.’ You can’t make that up. I guess we went out with a bang.”

Rodriguez then drove in a run with a line-drive double to right-center to tie the score in the bottom of the first.

But it was one of the players whom Rodriguez has mentored this season, Starlin Castro, who did the most damage. He hit a two-out, two-run single in the fourth and a two-out, two-run homer in the sixth to give the Yankees a 5-3 lead.

CC Sabathia (7-9) allowed three runs and four hits in six innings. Archer (6-16) allowed five runs and seven hits in six innings.

advertisement | advertise on newsday

A-Rod, feted with “A-Rod! A-Rod!” chants throughout, including during the Bleacher Creatures Roll Call, went 1-for-4. After his double in the first, he grounded to short in the fourth, struck out in the fifth and grounded to short in the seventh.

Girardi, who on Sunday had said he would “find a way” to play A-Rod as much as the DH wanted in Boston before backtracking Tuesday, was booed during pregame introductions.

Rodriguez opened up a bit about his relationship with his manager before the game.

“It’s been very difficult,” he said. “It’s been awkward and difficult. But we are family. We’ve had a wonderful relationship for the last 10 years. And it’s been really good. Families have disagreements. And that’s OK — he has his opinion, I have mine. But in the long run, we’re going to be fine.”

A-Rod said watching some of the younger players such as Castro and Gary Sanchez has had him thinking that this might be it. “I saw Gary Sanchez have a series in Boston,” he said, “and I looked at him and I said, ‘I can’t do that anymore.’ And I was happy about it. I’m at peace.”