BOSTON – First Josh Beckett couldn’t get an out.

Then he couldn’t catch a break.

Mark Teixeira hit a two-run single in a five-run first inning and a two-run triple in the seventh to give the New York Yankees the lead for good Friday night in a 10-8 victory against the Boston Red Sox.

Beckett allowed the first five batters to score and was booed on his way to the dugout after the top of the first. Then, after Boston rallied to tie the game and take a 7-6 lead, the bullpen coughed it up and cost Beckett a win.

“In the first inning, the strike zone was very hard for him to find,” Red Sox Manager Bobby Valentine said. “I’ve never seen him like that.”

Alex Rodriguez had three hits and Curtis Granderson scored three times for the Yankees, who improved to 3-0 against Boston this year.

David Ortiz and Adrian Gonzalez had three hits apiece for Boston, and Jarrod Saltalamacchia hit a three-run homer to help the Red Sox rally after Beckett gave up five runs in the top of the first. It was 5-5 when the inning ended.

“They got five in the first; we had their closer in at the end of the game,” Valentine said. “We did a good job but it put us climbing uphill the whole game.”

Rafael Soriano got four outs for his 20th save — his first save of more than one inning since 2007.

Boone Logan (4-0) wound up with the win and Andrew Miller (2-1) took the loss.

It was the first game between the rivals since the Yankees rallied from a 9-0 deficit with seven runs in the seventh and seven more in the eighth to win 15-9 on April 21 at Fenway Park.

The Yankees coughed up a 5-0 lead in the first and a 6-5 lead in the second, and Boston led 7-6 after five. But New York scored four times in the seventh inning, taking an 8-7 lead on Teixeira’s triple.

Raul Ibanez doubled in Teixeira and scored on Eric Chavez’s single to make it 10-7.

Beckett allowed six runs on eight hits and two walks, striking out five in five innings.

The first five Yankees reached — and scored — on three singles, a hit batter and a walk. When Beckett got Nick Swisher on a fly to right, the crowd cheered sarcastically, and it booed as he walked off the field at the end of the inning.

But Yankees starter Hiroki Kuroda was just as bad, giving up seven runs, six earned, on 10 hits and a walk while striking out three in 52/3 innings.

The Red Sox tied it in the bottom of the first, thanks in part to a two-run double by Gonzalez followed by Saltalamacchia’s career-high 17th homer.

The teams traded runs in the second inning before the pitchers settled down. The Yankees nearly took the lead in the fifth when Rodriguez singled and stole two bases. But he was thrown out trying to score on a grounder to second when Nick Punto came home with the throw and Saltalamacchia blocked the plate.

Boston took a 7-6 lead in the fifth when Gonzalez singled, took second on a wild pitch and scored on Mauro Gomez’s single — his first career RBI.

But the Yankees went ahead after Miller came in to start the seventh.

Granderson walked and Rodriguez singled, and,after Robinson Cano struck out, Vicente Padilla came on to face Teixeira, who lined a triple to the deepest part of the ballpark, the center-field triangle, just short of the 420-foot marker.

Granderson and Rodriguez scored and Teixeira slid into third without a throw.

The Red Sox threatened another comeback when Cody Ross led off the bottom half with a homer and Gonzalez singled. But Logan struck out Saltalamacchia and Cody Eppley came on.

Gomez singled, but Mike Aviles hit a grounder that drew Derek Jeter deep into the hole to his right and he threw to third for the force on Gonzalez. David Robertson struck out Punto with runners on second and third.