The Yankees went the first 38 home games of the season without a walk-off victory.

Then they had two in less than 24 hours.

Late Friday night, Brian McCann's three-run homer in the 12th capped a four-run rally, and Saturday afternoon, a throwing error allowed pinch runner Jose Pirela to score the winning run in the ninth as the Yankees beat the Rays, 3-2, in front of 35,508 at the Stadium.

"We were talking in the dugout during extras [Friday] that we hadn't had a walk-off all year," John Ryan Murphy said. "Two in a row is pretty fun."

Joe Girardi, whose club is 23-14 at home compared to 21-23 on the road, called it "a good way to start an important homestand."

The Yankees had to erase a two-run deficit in the bottom of the 12th Friday night, but their third straight win and the Rays' seventh straight loss was accomplished in an even less conventional manner Saturday.

advertisement | advertise on newsday

After Dellin Betances allowed a tying two-run homer by Steven Souza Jr. in the top of the ninth to foil Michael Pineda's bid for a victory, Mark Teixeira got the winning rally started against Rays righthander Brad Boxberger.

With first baseman James Loney guarding the line in no-doubles defense and the Rays' defense overshifted, Teixeira ripped a shot to the right of the diving Loney and to the left of diving second baseman Jake Elmore for a leadoff double into the rightfield corner.

Pirela ran for Teixeira and Chris Young -- who squared around to bunt on the first pitch -- fought back from an 0-and-2 count to draw a walk.

Then Ramon Flores, recalled from Triple-A Scranton/Wilkes-Barre on Friday, got ahead 2-and-0 before bunting toward the third-base side of the mound. Elmore couldn't make a backhand scoop of Boxberger's one-hop throw to first, and when Pirela saw the ball dribble away, he took off for home and slid across the plate ahead of Elmore's throw to Curt Casali.

The crowd, which had much of the wind taken out of it in the top of the ninth when Betances hung a 2-and-2 curveball to Souza, then got to enjoy watching Brett Gardner douse Pirela.

Yankees videos

"Whatever it takes," said Gardner, who singled against Nathan Karns and scored on Alex Rodriguez's bloop single to right before Teixeira hit a sacrifice fly in the first. "You feel like with Dellin on the mound, you've got that one wrapped up today. But Tex did a great job getting on base and some guys did some good things behind him. No matter how you win, what matters is you win."

It was the first homer allowed by Betances since Aug. 13, 2014. "That makes you go home a little happier," he said of the club picking him up in the bottom of the ninth. "A short memory is the key for bullpen guys and I'll be ready the next time out."

Pineda allowed five hits in seven shutout innings in his second straight stellar outing. He walked one and struck out 10.

"I want the win, but I'm focusing on my team winning the game," said Pineda, who at one point retired 12 straight batters and 18 of 19.

At the official halfway mark, the Yankees (44-37) lead the mediocre AL East by two games over the Orioles.

advertisement | advertise on newsday

"We're in a pretty good spot," Girardi said. "You could be in the alternative."

Said Gardner: "We're in first place. If you had told me we'd be a week before the All-Star break and in first place, you could sign me up for that."