OAKLAND, Calif. - It may be hard to believe, but the once struggling Oakland Athletics are only two games under .500 after sweeping the first-place Los Angeles Dodgers.

Yoenis Cespedes crushed a line drive three-run homer just inside the foul pole in the bottom of the ninth as the A's beat the Dodgers 4-1 on Thursday.

The A's have won eight of their last nine games and will welcome the rival San Francisco Giants for a three-game weekend series.

John Lindblom replaced Clayton Kershaw in the bottom of the ninth for the Dodgers. Coco Crisp led off with a walk, advanced to second on a wild pitch and reached third on a bunt single by Jemile Weeks. That set it up for Cespedes' heroics. He homered on an 0-1 count for his first career walk-off hit.

Jonny Gomes doubled to left to lead off the second inning for the A's. He advanced to third on a wild pitch and scored on a sacrifice fly from Brandon Inge.

A's starter Travis Blackley was perfect through 3 1/3 innings, retiring the first 10 batters. Elian Herrera doubled to left-center, giving the Dodgers their first base runner. With two outs, Juan Rivera reached out and singled down the right-field line to score Herrera, tying the

game at 1-1.

Kershaw and Blackley then were toe-to-toe in a pitcher's duel. Kershaw retired 18 of 21 batters, including 13 consecutive, while Blackley set down eight straight and 12 of 13 Dodgers. Both pitchers each allowed only three hits through eight innings.

A's closer Ryan Cook came in to pitch the ninth. Cook proceed to walk Matt Treanor to lead off the ninth.

Dee Gordon tried to sacrifice, but his bunt attempt went toward third base. Inge barehanded the ball and fired a strike to second base to get Treanor by a step. With Gordon on first, he tried to steal second base but was gunned out by catcher Derek Norris in his Major League debut.