Updated

Yoenis Cespedes hit a go-ahead home run in the eighth inning and the Oakland Athletics swept a three-game series against the Kansas City Royals with a 4-3 win.

Leading off the eighth, Cespedes knocked a 1-0 pitch off Kelvin Herrera (2-4) deep into left center.

Oakland reliever Ryan Cook allowed runners on second and third with two outs in the ninth, but managed to escape and notch his first save of the season.

Coco Crisp, Jed Lowrie and Josh Donaldson contributed with an RBI apiece for the Athletics.

"We got some timely hits," said Donaldson. "As of the last three (games), our guys have kept us in it and we've been able to get the timely hits."

Oakland starter A.J. Griffin allowed three runs on seven hits and three walks in six frames. Jerry Blevins (3-0) pitched a scoreless eighth to pick up the win.

Alex Gordon, Eric Hosmer and Chris Getz each drove in one run for the Royals, who have lost seven of their last nine games. Starter Luis Mendoza gave up three runs -- two earned -- on eight hits in six-plus innings.

"It's just too bad," said Getz. "We got to bounce back, get through this and continue on."

Gordon singled with two outs in the third, scoring Getz, who drew a walk and advanced to third on a single by Alcides Escobar. Hosmer walked to start the fourth and scored on a single by Getz.

The Athletics responded in the bottom of the inning with back-to-back singles by Cespedes and Brandon Moss. Donaldson then hit a sacrifice fly to right, bringing Cespedes home.

In the fifth, Hosmer smacked a double into center, plating Gordon, to make it a 3-1 game.

However, Eric Sogard hit a double in the home half and later scored on a single by Lowrie to cut the deficit to 3-2.

Derek Norris singled to lead off the eighth and strangely reached third on a fielding error by David Lough in center. Crisp's sac fly to left scored Norris and tied the game.

In the ninth, Cook got two quick outs before allowing a single by Billy Butler. Elliot Johnson pinch-ran and reached third on a single by Hosmer, who advanced to second on a fielder's indifference. Mike Moustakas, however, grounded out to second to end the game.

Game Notes

Gordon went 4-for-5 ... Blevins has not allowed a run in 17 of his 18 career appearances against Kansas City ... The Royals were 3-for-10 with runners in scoring position and left 12 runners on base ... Kansas City has recorded just 12 runs in the last seven games in Oakland, going 1-6.