BOSTON — The Red Sox’s horrible start to the season didn’t put pressure on Josh Beckett to pitch one of the best games of his career.

He did anyway.

Beckett allowed two singles and one walk and struck out 10 in eight innings, a rare strong outing by a Boston starter that led to a 4-0 win over the New York Yankees on Sunday night. The Red Sox took two of three games from their rivals after starting the season 0-6 on the road.

“When our turn (in the rotation) comes, we’re not thinking about what happened yesterday or in the future,” Beckett said. “You just take it really day by day.”

Beckett (1-1) retired the first seven batters he faced and the last 14. He allowed singles to Eric Chavez in the third inning and Robinson Cano in the fourth. Only two of his outs made it to the outfield.

The right-hander was dropped to fourth in the season-opening rotation after going 6-6 with a 5.78 ERA in an injury-plagued 2010 season. He faced the Yankees five times last year, going 1-2 with a 10.04 ERA. Going into Sunday’s game, Red Sox starters were 1-5 with a 7.41 ERA this year.

That all changed with Beckett’s start Sunday against Yankees ace CC Sabathia (0-1).

“It was great, one of his best,” catcher Jason Varitek said. “We needed a good, quality start, especially when you have that other guy on the mound over there. And we got a huge, quality start out of Josh.”

After losing three games in Texas and another three in Cleveland, their worst start to a season since they lost the first eight in 1945, the Red Sox won their home opener 9-6 on Friday before losing 9-4 on Saturday.

“I think we were just ready to come home,” Beckett said. “That was a pretty tough break, what we went through on the road.”

Jonathan Papelbon struck out two of the three batters he faced in the ninth in a non-save situation.

Dustin Pedroia reached base all five times he went to bat with three singles — all against Sabathia — an intentional walk and a force play. He got on base in 10 of his last 11 trips to the plate as the Red Sox won despite stranding 16 runners, including three in both the sixth and seventh innings.

Beckett retired four of the first seven hitters on strikeouts before Chavez singled to center and Russell Martin was hit by a pitch. But Brett Gardner grounded into a double play, “the biggest part of the game,” Varitek said.

Beckett struck out Derek Jeter to start the fourth then walked Mark Teixeira, who took second on Cano’s single, the last Yankee to reach base in the game. Beckett got out of the inning by striking out Curtis Granderson and retiring Nick Swisher on a ground ball.

“From the very beginning, he was commanding all of his pitches,” Boston manager Terry Francona said. “He was really, really good.”

Alex Rodriguez had flulike symptoms and was a late scratch from the New York lineup.

“He looked wiped out,” Yankees manager Joe Girardi said. “Hopefully, the rest today and the rest tomorrow (a day off for the team) and he’ll be back at full strength.”

The Red Sox took a 1-0 lead in the third on Mike Cameron’s RBI single but kept wasting opportunities as they stranded 12 runners through six innings.

“CC knows how to get out of situations,” Girardi said. “I think we’re going to have a lot of tough games with them.”

The Red Sox finally scored again in the seventh on Marco Scutaro’s two-run single. David Ortiz began the inning with a walk and Cameron struck out, but J.D. Drew walked and Varitek singled, loading the bases for Scutaro.

Boston made it 4-0 in the eighth on a leadoff walk to Kevin Youkilis and a long double off the center field wall by Ortiz.

A baserunning gaffe by Youkilis cost the Red Sox a run in the second. Boston loaded the bases on singles by Pedroia and Gonzalez and a walk to Youkilis. Ortiz grounded to second baseman Cano, who threw for an apparent force out at second to Jeter, whose relay to first got Ortiz.

Pedroia went home and Gonzalez took third on the play. But Youkilis was called out for leaving the baseline, sending Pedroia back to third and Gonzalez to second while allowing the out on Ortiz at first. Cameron then singled home Pedroia before Drew struck out.

Notes: Beckett struck out at least 10 for the 11th time and first since July 27, 2009. … Teixeira was 0 for 12 in the series. … Red Sox RHP Clay Buchholz and the team agreed to a four-year deal through 2015 that includes club options for 2016 and 2017. He was second in the AL with a 2.33 ERA and made the All-Star team last year but is 0-2 with a 7.20 ERA this season. … Cano has reached base in 16 straight games at Fenway Park, starting on June 11, 2009. … Sabathia is winless despite a 1.45 ERA in three starts. … Drew has reached base in all seven games he’s played this year.