Oakland’s Eric Sogard scores the winning run in the 10th inning as Baltimore catcher Matt Wieters awaits a late throw from left field after a throwing error — the Orioles’ second of the inning — by third baseman Manny Machado on a play at third. (Marcio Jose Sanchez/Associated Press)

Leading by five runs in the sixth inning, the Baltimore Orioles appeared to be cruising to their first four-game sweep of the Athletics at Oakland Coliseum in 26 years.

But it couldn’t be that easy, not in Oakland, not against an A’s team that the Orioles had previously swept just once in a four-game series — in May 1987 — in the clubs’ histories.

The A’s stormed back in the sixth, tied the game in the seventh, returned the lead in the eighth and then tied it again in the bottom of the ninth with a two-run homer by Cuban star Yoenis Cespedes, who was playing in his first game since coming off the disabled list.

When the dust settled, the A’s won, 9-8, on consecutive bad throws on attempted sacrifice bunts. It ended on a walk-off error.

It was that kind of game.

In the bottom of the 10th, Pedro Strop (0-1) allowed a leadoff single to Eric Sogard. Adam Rosales dropped a bunt that Strop fielded and threw into center field in an attempt to get Sogard at second.

With two on, Coco Crisp bunted and third baseman Manny Machado grabbed the ball and threw wildly past shortstop J.J. Hardy at third in an attempt to get Sogard. The ball ended up in left and Sogard, who at first didn’t realize where the ball went, dashed home well ahead of left fielder Nate McLouth’s throw.

Baltimore (15-10) is now 3-1 on a three-city road trip out west.

Oakland (14-12) had dropped four in a row and eight of its past nine before Sunday’s victory. The Orioles scored four runs in the fourth, by sending eight batters to the plate against Bartolo Colon. Chris Davis had a two-run double, Adam Jones an RBI single and Matt Wieters a sacrifice fly.

McLouth triggered the rally with a leadoff single — one of four hits he had in the game. He scored four runs and has reached base in 22 of his last 36 plate appearances. Not to be outdone, Machado had four hits, drove in two and scored once.

Davis homered in the eighth, his AL-leading ninth of the season.

This series, the typical top five in the Orioles’ lineup — McLouth, Machado, Nick Markakis, Jones and Davis — combined to go 33-for-82 (.402 average) with five homers, 21 runs scored and 22 RBI.

Baltimore right-hander Miguel Gonzalez had barely broke a sweat in his first five innings, allowing just two hits while throwing 65 pitches. But he absolutely unraveled in the sixth, throwing 40 pitches and giving up four runs on five hits and two walks (one intentional).

That’s the most pitches thrown by an Oriole in one inning this season, and it ruined Baltimore’s shot of having four consecutive quality starts. Of the 17 runs Gonzalez has allowed this year, eight have come in the sixth inning.

— Baltimore Sun