Bad habits are knocking the Twins out of the AL Central race.

Kyle Gibson can’t stop putting the first batter he sees each inning on base. And the Twins’ frustrating custom of losing to the Yankees, especially in Minnesota, goes way, way back.

Gibson put New York’s leadoff hitter on base four times in six innings Sunday, and it eventually cost him dearly in a 7-2 loss that dropped Minnesota 7 ½ games behind Kansas City in the playoff race. Chase Headley led off the fifth inning with a 420-foot blast onto the right field plaza, then drove in two more runs in the Yankees’ six-run sixth inning, helping New York remain perfect in this ballpark: The Twins never have won a series from them in Target Field.

“Everybody knows the history here,” Twins manager Paul Molitor said of New York’s seven consecutive series victories in the Twin Cities. “We let one slip away yesterday, and sometimes those things carry over somewhat.”

Losses to the Yankees must be carrying over for years, considering Tom Kelly was the manager the last time the Twins won a season series from New York, back in 2001. The Twins outscored the Yankees 15-1 over the first 12 innings of this series, and could dream about a sweep.

“You get a little greedy,” Molitor shrugged.

Then they got outscored 15-2 over the final 15 innings, leaving them frustrated over dropping their third straight series since the All-Star break.

“It’s pretty disappointing,” Gibson said. “We jump out to a lead in all three games, and still lose the series.”

His lead was only 1-0, and never felt very secure, not with the Yankees constantly threatening. Gibson, who fell to 8-8 on the season with his second consecutive six-run start, has allowed the first batter to reach base 10 times in his past 14 innings, which means he’s constantly working out of trouble. He’s good at it — the 22 double plays he has induced are the most by any pitcher in the majors this year — but it makes the workload much heavier.

“It takes a toll on you when you’re constantly battling out of jams, even if they’re mini-jams,” Molitor said. “A lot of situations he was able to work around early, but when you’re constantly trying to have to make pitches to get out of innings, it’s going to take its toll.”

It seemed to Sunday. Gibson worked around a leadoff double by Carlos Beltran in the second inning and kept Stephen Drew from scoring after hitting him with a pitch to open the third. But Headley’s homer was a leadoff mistake that cost Gibson that 1-0 lead his teammates had provided, and Brett Gardner’s leadoff single in the sixth inning sparked an uprising that Gibson couldn’t contain.

“I kind of lost it for three hitters,” Gibson said. “It happened really quickly.”

Yeah, exactly 10 pitches. Gardner hit the first pitch he saw, “right over the middle of the plate,” Gibson complained, and then Mark Teixeira and Brian McCann took back-to-back walks on just nine pitches.

“I felt pretty good up until then,” Gibson said. “But that really kind of turned what I thought was going to be a pretty decent day into a sour day.”

He struck out Beltran, but then long-ago Twin Garrett Jones drilled a single to right to give the Yankees the lead. Headley followed with a two-run single, and Gibson’s day was done. Jones scored when Didi Gregorius executed a squeeze bunt against reliever Ryan O’Rourke, and Headley trotted home when Drew clobbered an O’Rourke pitch into the right-field overhang seats.

Gibson, who allowed six runs in just 5 ⅓ innings, has inflated his ERA from 2.85 to 3.48 in six days.

“He’s still doing fine. He gave us a chance. It just kind of fell apart there and we just didn’t get anything going” against Yankee starter Nathan Eovaldi, who allowed eight hits, all singles, and just one run in eight innings, Molitor said. “You take your medicine, you lose the series, and you’ve got to move on.”

The Yankees are moving on to Texas. That’s the best part for the Twins.