Finally, the Yankees got some production out of first base. From a guy they don’t want to have to play at first base. And it helped them get back into first place.

Matt Holliday, who got a rare start at first because of the struggles of Chris Carter, slugged a tiebreaking home run in the fifth inning and the Yankees went on to snap a seven-game losing streak with an 8-4 victory over the Angels before 39,911 Wednesday night at Yankee Stadium.

Holliday was making the 16th start at first in his 1,838-game big-league career and seventh this season. The Yankees signed the longtime outfielder to be their designated hitter believing the 37-year-old’s back can’t handle more than a few cameos in the field. But with an MLB-worst .598 OPS from their first basemen going in, the Yankees know they need more sock from the position.

So Holliday started there and may have regretted it immediately. He overran and completely missed a foul pop-up hit by Andrelton Simmons leading off the second. Even though the ball did not touch his glove, Holliday was charged with an error, one that did not end up costing the Yankees.

“I missed the pop-up,” Holliday said. “I’m used to catching them in the outfield.”

Much more likely to end up in Holliday’s personal highlight reel was the 2-and-2 fastball from Ricky Nolasco (2-9) that he deposited in the rightfield seats.

advertisement | advertise on newsday

Holliday’s 15th home run gave the Yankees a 3-2 lead that they never relinquished. They moved back into first place in the AL East after a one-day absence. They lead the Red Sox — who lost in Kansas City, 6-4 — by one-half game.

“It’s nice,” manager Joe Girardi said. “It’s been a frustrating week, there’s no doubt about it. Especially with the way we’ve lost some of these games.”

The Yankees had been in sole possession of first for a solid month before the losing streak knocked them down.

Holliday said preparing to play first is what causes some discomfort in his back. But he also said he’d be willing to do it more than once a week “if that’s something they’re interested in doing.”

Said Girardi: “It’s really talking to him about physically what he thinks he can handle. He stiffens up sometimes when he plays first base by the end of the game. What happens the next day? That’s your concern. There’s things we can talk about, but I don’t feel like I can do it too much.”

Yankees videos

The Yankees staked Jordan Montgomery to a 2-0 lead in the second when Didi Gregorius hit a two-run shot, his eighth home run. The Angels tied it in the fourth on Martin Maldonado’s towering two-run homer to left. Montgomery (5-4) went 5 2⁄3 innings and allowed just those two runs and five hits with two walks and five strikeouts.

After Holliday gave the Yankees the lead in the fifth, Girardi had Dellin Betances ready for a two-inning appearance if it had still been a one-run game in the seventh. But the Yankees opened a bigger cushion with a three-run sixth. Austin Romine (3-for-4) had a two-run double and Aaron Hicks added a two-out RBI infield hit to make it 6-2.

Holliday’s big night continued as he legged out a double leading off the seventh and scored on Starlin Castro’s single. Chase Headley’s two-out single gave the Yankees an 8-2 lead.

Betances, who needed work, struck out two in a perfect eighth. Tyler Clippard, the losing pitcher Tuesday, started the ninth and gave up a double to Simmons and a two-run homer to Maldonado to make it 8-4. He was removed to a chorus of boos.

That forced Girardi to bring in Aroldis Chapman, who retired all three men he faced, striking out Eric Young Jr. to end it.

advertisement | advertise on newsday

“It’s over,” Girardi said, meaning the losing streak.