Oakland’s Josh Donaldson connects on the winning three-run homer off Baltimore’s Zach Britton. (Ben Margot/ASSOCIATED PRESS)

The Baltimore Orioles entered the ninth inning Friday night on the verge of beginning the second half in spectacular fashion.

Third baseman Manny Machado silenced Oakland A’s fans with a two-run, go-ahead homer in the seventh inning and the Orioles were on their way to opening their three-city, 10-game West Coast road trip with a win over the team with the best record in baseball.

It all unraveled quickly, and ended in the ninth inning on Josh Donaldson’s three-run walk-off homer off Zach Britton, sealing a devastating 5-4 loss at the O.co Coliseum.

Britton, who had converted 15 of 17 save opportunities and 10 straight, was unable to get an out in the ninth. Yoenis Cespedes reached on an infield single to Machado and Brandon Moss looped a single to right.

Donaldson then blasted a Britton delivery over the center field fence, prompting a celebration at home plate.

It had been nearly five weeks since Machado tossed a bat into the field of play in a game against the Athletics at Camden Yards — earning an ejection and eventual five-game suspension — an incident that came two days after Machado had a confrontation with Donaldson for what he believed was a rough tag.

When Machado was introduced for pregame introductions, Oakland fans booed. When he took third base in the first inning, they booed. When he received the ball following a strikeout, they booed. And when Machado stepped up to the plate, they booed louder.

They waved large signs with Machado’s face, some with a pacifier in his mouth, others with tears running down his face. One adult fan dressed like a baby, complete with an orange blanket and baby bottle.

Before the game, Machado said he put the June 8 incident in the past — as well as the first half that ended with the Orioles atop the American League East at the break.

Right-hander Chris Tillman recorded his seventh quality start in his past eight outings, holding Oakland to two runs over four hits over 62 / 3 innings. He struck out six and walked just one. Tillman has allowed three earned runs or fewer in each of his past eight starts.

— Baltimore Sun