BOSTON -

The Oakland Athletics earned a character win Sunday, the kind that can keep a team in first place.

"No question about it," manager Bob Melvin said after his American League West-leading A's avoided a three-game sweep at the hands of the Boston Red Sox with a 3-2 victory in 10 innings Sunday.

"We've played a few of these games over the years with this group -- this is one that we get it handed to us a couple of times and now we got to fight as hard as we can with basically nobody on the bench ... a left fielder who's limping around a little bit. Everybody contributed today so this team has been shown to be very resilient at times."

The left fielder Melvin was talking about is Yoenis Cespedes who, playing on a sore hamstring, barely beat out a bases-loaded, infield hit with two out in the top of the 10th to give the A's the win.

"It was great," said third baseman Josh Donaldson. "Nobody wants to get swept by a team."

The A's failed to hold 1-0 and 2-1 leads on Sunday, but managed to win to go to 19-12, and finish off a 6-4 trip.

Left-hander Chris Capuano (1-1) got the first two outs in the 10th before shortstop Jed Lowrie doubled. Donaldson was walked intentionally and pinch hitter Alberto Callaspo unintentionally to load the bases.

Right-hander Burke Badenhop relieved and Cespedes hit a slow bouncer up the third-base line. Third baseman Will Middlebrooks bare-handed the ball but his throw was just a bit late.

Right-hander Jim Johnson, removed from the closer's role early last month, got a double play ball to end the ninth and then pitched out of trouble in the bottom of the 10th to end the game.

Johnson (3-2) got help from first baseman Daric Barton, who entered the game in the ninth inning. After Middlebrooks singled and took second on an error by center fielder Coco Crisp, Barton fielded a grounder and threw Middlebrooks out at third on a gutsy play.

"I was breaking off the bat," said Middlebrooks. "I didn't know it was to his right, to his left or right at him. Unfortunately it was right at him. This is the big leagues. People are supposed to make plays like that. Normally you don't see a first baseman that far in, but he made a good play. Hats off to him."

The loss again kept the Red Sox (15-17) from getting back to .500 for the first time since they were 2-2.

Boston closer Koji Uehara escaped a jam in the ninth, getting right fielder Josh Reddick to hit into a double play. Reddick left the game with a left ankle sprain that kept him from running hard to first base.

A.J. Pierzynski hit a game-tying solo home run in the seventh inning, the catcher's second homer of the season and first career home run at Fenway Park.

After left fielder Grady Sizemore tied the game with an RBI double in the fifth inning, Pierzynski led off the seventh with only the second homer of the year off starter Sonny Gray, who turned in another strong start (on the heels of his first big-league shutout).

The Red Sox, with the help of a wind-blown error by Reddick, then had runners on second and third with nobody out but relievers Fernando Abad and Luke Gregerson got out of the inning.

Red Sox starter John Lackey pitched the first six innings, allowing two runs in the sixth straight quality start for Boston, two of them by Lackey.

The A's scored a run in the first inning when, with two out, Donaldson walked, stole second and scored on first baseman Brandon Moss' soft single.

Donaldson singled with two out in the third and was thrown out in a close play at the plate on Moss' double. Having lost a challenge in the first inning, Melvin had to ask umpire crew chief Jeff Kellogg for a review, saying Pierzynski blocked the plate under the new rule. The umpire agreed to review, but the call was confirmed.

NOTES: Red Sox 1B Mike Napoli rested his injured left ring finger but entered the game late, while RHP Edward Mujica is day-to-day with oblique tightness. ... Oakland manager Bob Melvin challenged and lost on the first play of the game and then lost another review (called by the umpire crew chief) on an out call at the plate in the Oakland third. The two "losses" dropped the A's to 7-4 on reviews. ... LHP Scott Kazmir, off to the first 4-0 start of his career and 6-0 dating back to last season, opens Oakland's 10-game homestand against the Seattle Mariners on Monday night. ... The Red Sox, off Monday, host the Cincinnati Reds Tuesday and Wednesday. LHP Felix Doubront, winless in five starts since winning his first time out, pitches for Boston on Tuesday. He is 5-1 in six career starts against the National League but has never faced the Reds.