NEW YORK — Mariano Rivera stood on the mound, looking down at his cleats. Somehow, he’d let yet another lead slip away.

Never before had baseball’s all-time saves leader blown three straight chances.

Silenced by a pair of Detroit home runs, the fans at Yankee Stadium soon perked up. Brett Gardner homered with two outs in the bottom of the ninth inning, lifting the New York Yankees over the Tigers 5-4 Sunday for their first series win in more than a month.

Rivera has a record 643 saves, but had never failed three in a row in 1,087 previous relief appearances. His troubles began in Chicago, where he gave back a lead to the White Sox.

“At least it’s the first time, you know what I mean?” Rivera said. “I just try to go out there and do my job. The last three opportunities, I haven’t done it. So we have to continue battling and get better. Have to keep working and eventually it will happen.”

Rivera blew both save chances in this series. Gardner provided the winning hit in both games.

“Mo’s bailed us out a few times,” Gardner said. “It didn’t matter if it was me or somebody else, we just needed to get a win today and I’m glad we made it happen.”

Rivera (3-2) gave up another homer to a limping Miguel Cabrera, plus a drive to Victor Martinez in the top of the ninth. The solo shots made it 4-all and turned Alex Rodriguez’s first homer of the season into a footnote.

But Gardner connected off Jose Veras (0-5). The feisty center fielder flipped his batting helmet to A-Rod just before reaching the plate, then jumped into a cluster of teammates at home.

“To Martinez, that ball was just laying right flat up. And also with Miguel,” Rivera said. “You’re facing professional hitters. If you don’t put the ball where you need to, you’re going to get hit.”

On Friday night, Rivera gave up a two-run shot to Cabrera, who fouled two balls off his leg before launching the tying drive. Gardner won it in the 10th with a single.

Manager Joe Girardi is hardly going to start worrying now about the 43-year-old pitcher generally regarded as the best closer ever.

“It’s not like you forget how to pitch in a week,” Girardi said. “It’s impossible.”

Alfonso Soriano homered for his 2,000th hit in the fourth inning. He connected off Justin Verlander, as did Rodriguez.

“All great pitchers have one thing in common: they attack you and throw strikes,” Rodriguez on why he’s had success against Verlander — four homers in 28 at-bats.

Rodriguez, who has missed most of the year while coming back from hip surgery, hit a leadoff homer in the second. His 648th career home run pushed him past Stan Musial for fifth on the RBIs list with 1,951.

“It was a tremendous homer by A-Rod,” Pena said. “Justin Verlander threw a great inside pitch and he used his hands and sometimes you just have to credit the hitter.”

Lustily booed Friday night in his season debut at Yankee Stadium, he quickly turned fans around Sunday with a soaring shot to left field that made it 1-all. Rodriguez drove in one more run with a single down the first base line in the third.

“Felt good to get the first one out of the way,” Rodriguez said. “Today was a step in the right direction.”

Late lineup-addition Brayan Pena homered in the eighth off Yankees setup man David Robertson, cutting Detroit’s deficit to 4-2.

Pena played for Alex Avila, who was placed on the 7-day concussion list after the game. Avila was hit in the mask by a foul ball Thursday but played Saturday. He was in the initial lineup Sunday.

On a glorious August afternoon in the Bronx, the Yankees avoided dropping to .500 for the first time since April 13, improving to 59-57. Taking two of three from the AL Central leaders gave New York its first series win July 5-7 after an 0-5-3 stretch.

Gardner started a long-distance double play to end the eighth inning by leaping against the center field wall to catch Torii Hunter’s fly and preserve the 4-2 lead.

Prince Fielder had an RBI single in the first off Andy Pettitte, the eighth straight game the lefty allowed a run in the opening inning. That’s the longest such streak by a Yankees pitcher, according to STATS research back to 1920.

Rodriguez made a stellar play in the eighth when he reached deep behind third base on Austin Jackson’s grounder and threw to second to nail Jose Iglesias for the first out.

Tigers manager Jim Leyland disputed the call, and TV replays appeared to back him up.

Leyland was back on the field one batter later. Shaken after catching Hunter’s fly, Gardner flipped the ball to Soriano. The left fielder threw the ball to shortstop Eduardo Nunez, who tossed it to second baseman Robinson Cano. Cano easily tagged Austin Jackson, who stood confused on second base.

“As I lowered my head as I rounded back to make sure I stepped on second base, I saw the ball on the ground so I thought it hadn’t been caught,” Jackson said. “Sometimes you have no way of telling what’s going on behind you. It happens sometimes. He made a great catch.”

Half the team met Gardner at the dugout steps to congratulate the center fielder. They all pounced on him after his homer.

NOTES: Verlander gave up seven hits and four runs in seven innings. He struck out nine and walked one. ... Rodriguez was given an error in the third on Martinez’s slow roller that he ran in for but couldn’t scoop with his glove. ... Rodriguez’s two hits were his first off a right-hander in 25 at-bats dating to last year’s playoffs. ... The Tigers recalled C Bryan Holaday from Triple-A Toledo after the game.