Mark Trumbo eliminated any chance of a repeat in the 12th.
Trumbo led off the bottom of the 12th inning with his 44th homer of the season and the Baltimore Orioles rallied past the Arizona Diamondbacks 3-2 on Friday night.
"We'll take it, especially after having a few chances," Trumbo said. "This is the type of game you definitely want to win because it can be a real gut punch if it goes the other way."
Trumbo lined a 1-2 fastball from Matt Koch (1-1) into the left field seats to snap a four-game losing streak for the Orioles (83-71).
"I was trying to be away, expand (the zone) a little bit, came back over the middle," Koch said. "Good pitch to hit."
Baltimore remains a 1/2 game behind Toronto and Detroit, both of which won Friday night, in the wild-card standings, but may have regained its momentum.
"Momentum is your next game, it really is," manager Buck Showalter said. "I'm glad our guys feel good about themselves for one night, they've been frustrated. They've earned the right to play these meaningful games and I'm happy for them."
Baltimore won despite stranding 14 baserunners, thanks to three solo home runs.
"They did a great job of battling back and tying the game and we did a great job of stopping them from winning the game a couple of times," Diamondbacks manager Chip Hale said.
Oliver Drake (1-0) pitched one inning for the win. Baltimore relievers combined for six scoreless innings.
"We've had a lot of guys we've had to push because of the end of the season but they've handled it well," Showalter said, "and we've been able to keep the wolves at bay because of the job those guys are doing."
Pedro Alvarez homered off reliever Enrique Burgos with two outs in the eighth to pull the Orioles within 2-1.
Jake Lamb and Jean Segura drove in runs for the Diamondbacks (64-89).
Arizona starter Shelby Miller, looking for his first win since June 20, threw six scoreless innings. He allowed just three hits and three walks, while striking out three. It was Miller's first start of the season in which he didn't allow a run.
"Honestly, since I've been back I've felt like I've been throwing the ball good," said Miller, who spent over a month at Triple-A Reno during the summer.
"Some of the games the results haven't been that great, but I've been feeling pretty good with my stuff. This is a huge boost for me against a tough team, tough lineup."
Orioles starter Yovani Gallardo gave up two early runs, but turned in a solid six-inning effort. He allowed two runs on six hits while walking two and striking out five.
Gallardo got two quick outs in the first, but then walked Paul Goldschmidt. Back-to-back singles by Wellington Castillo and Lamb made it 1-0.
The Orioles have given up first-inning runs in 59 of 154 games this season.
Miller struck out Alvarez with the bases loaded to escape trouble in the bottom of the first.
Arizona went up 2-0 in the second when Brandon Drury led off with a double and scored on Segura's two-out double off right fielder Trumbo's glove at the wall.
NOTES: Arizona manager Chip Hale said RHP Zack Greinke (shoulder soreness) had an MRI on Friday that showed no structural damage, but Greinke will probably not start against the Nationals early next week. ... 3B Manny Machado was voted the winner the 2016 Most Valuable Oriole Award by members of the local media who cover the team on a daily basis. ... Orioles manager Buck Showalter said RHP Kevin Gausman (oblique soreness) felt good on Friday and remains on track to start Tuesday or Wednesday in Toronto. ... Baltimore LF Hyun Soo Kim hit leadoff for the second time this season, while CF Adam Jones batted second. ... It was Arizona RHP Shelby Miller's first career start against the Orioles. ... Arizona pitchers brought the highest ERA in the Majors (5.19) to Camden Yards. ... Diamondbacks designated hitters haven't homered since Yasmany Tomas hit one on June 15, 2015.