The A's trailed 4-3 entering the bottom of the eighth, but scored two times to take the lead. Matt Joyce hit a leadoff double off reliever Brad Brach (3-3) and moved to third on Marcus Semien's single to left. Lowrie brought Joyce home with a ground-rule double to right-center, pulling the A's even. Semien moved to third.
With one out, Chad Pinder hit a foul popup down the right field line that first baseman Chris Davis dropped for an error. Pinder made the Orioles pay, driving in Semien with a sacrifice fly to right field, giving Oakland a 5-4 lead.
Right-hander Blake Treinen pitched a perfect ninth for his third save with the A's and sixth for the season.
Orioles right-hander Ubaldo Jimenez allowed three runs on six hits over 5 1/3 innings with a season-high 11 strikeouts and one walk. But he left the game after being hit on the lower right leg by Pinder's hard ground ball that went for a one-out infield single.
After being examined by a trainer, Jimenez limped off the field to the dugout with a 4-3 lead.
The Orioles, who are in the American League wild-card playoff race, fell two games under .500 at 57-59.
Tim Beckham went 2 for 4 and extended his hitting streak to 11 games to begin his Orioles career since coming to Baltimore from Tampa Bay on Aug. 1 in a trade. He also scored a run.
A's rookie right-hander Paul Blackburn allowed four runs on 10 hits over 5 2/3 innings in his eighth career major league start. He struck out three and walked two. Simon Castro pitched 1 1/3 perfect innings and Santiago Casilla (3-5) pitched a perfect eighth.
The Orioles, who hit four home runs in a 7-2 victory against Oakland on Thursday night, took a 1-0 lead in the top of the second inning on Adam Jones' leadoff shot and second homer in two days. He lined Blackburn's 1-2 fastball over the left-field fence.
Baltimore made it 2-0 with a run in the fourth. Manny Machado blooped a leadoff double down the left field line and moved to third on Jonathan Schoop's single. Machado scored when Jones grounded into a double play.
The A's scored three runs in the bottom of the fourth to take a 3-2 lead. Lowrie lined a leadoff double to left-center and scored on Khris Davis's opposite-field double down the right field line.
Olson launched a two-run homer to deep center with one out, crushing Jimenez's 2-1 fastball for his fifth homer of the season.
Baltimore regained a 4-3 lead in the fifth when Beckham and Machado had back-to-back singles and Schoop hit a two-run double to right-center.
NOTES: OF Boog Powell and RHP Micheal Brady were called up from Triple-A Nashville by Oakland on Friday. Powell, who was acquired Sunday from Seattle in exchange for 1B Yonder Alonso, was initially in the starting lineup in center field but was a late scratch because of an illness. OF Rajai Davis replaced Powell in the lineup. ... A's OF Jaycob Brugman and OF Mark Canha were optioned to Triple-A Nashville. ... Orioles 1B Chris Davis, who has been struggling at the plate, returned to the starting lineup Friday against Oakland after getting a day off Thursday. Orioles manager Buck Showalter had Davis hit seventh in the lineup for the first time since 2014. He hit lower than fifth this season for the first time. ... DH Mark Trumbo moved down in the order and hit sixth for the second time this season. ... A's 3B Matt Chapman, who left Thursday night's game after the third inning with an illness, was in the starting lineup again Friday night. Chapman said he had food poisoning Thursday. ... A's rookie RHP Bobby Wahl will undergo thoracic outlet surgery on his right arm on Monday, the A's announced. The surgery will be performed in Dallas by Dr. Greg Pearl, a vascular surgeon and specialist in the procedure.