After allowing a two-run homer and three hits in the first, CC Sabathia coasted for six innings against the Texas Rangers’ potent lineup Tuesday night. He looked like the pitcher who had gone 4-2 with a 0.82 ERA in seven starts from May 4 to June 16.

Then the eighth inning happened.

Sabathia did not pitch poorly, other than hitting Shin-Soo Choo to begin the frame. In fact, he said he executed his other pitches.

But his line in the boxscore had more in common with his previous start — five earned runs in 4 1⁄3 innings against Colorado — than the seven before it.

Sabathia exited after Ian Desmond, Adrian Beltre and Prince Fielder followed Choo with three straight hits, doubling Texas’ lead. After Joe Girardi pulled Sabathia, Anthony Swarzak allowed three more runs, two of which were charged to the starter.

The Yankees lost, 7-1, and Sabathia finished with six earned runs, eight hits, one walk and two strikeouts.

advertisement | advertise on newsday

“It was just frustrating, that last inning,” said Sabathia, who fell to 5-5 after his ERA rose to 3.17.

After Choo reached leading off, Sabathia knocked down Desmond’s comebacker. He could not locate the ball on the ground, and both Choo and Desmond were safe.

“If I can either make the play or get out of the way, I have a double play right there,” Sabathia said.

Then Beltre, who homered in the first, hit a sharp grounder to third baseman Chase Headley. At the last second, the ball changed course and skipped into leftfield, allowing Choo to score.

“That ball, I’m thinking triple play off the bat, or at least trying to, and it just took a right turn on me,” Headley said. “It was going to square me up right in the middle of the body, and then for whatever reason, it kicked that way.”

Yankees videos

Fielder doubled in Desmond, and Girardi removed Sabathia, who — for Yankees fans looking for a silver lining — said his twisted right ankle “felt good.”

“We should have been out of that inning with no runs,” Girardi said. “It should have been 2-0 after the eighth, but it happens.”

With that, the Yankees fell to 37-39. They need to win Wednesday and Thursday to split the four-game set with Texas (51-27) before traveling to San Diego.

“I wish I could have done something different,” Headley said. “It’s unfortunate for CC because he threw the ball so well and ends up with some earned runs there he doesn’t deserve.”