Zach Davies (2-5) allowed one run and four hits in six innings for his first victory since June 7. He struck out six and walked one while helping the Diamondbacks (70-65) end a three-game slide.
Paul Sewald tossed a scoreless ninth inning for his eighth save in 10 opportunities since being acquired from the Seattle Mariners at the trade deadline. Sewald has 29 saves overall.
Ryan O'Hearn drove in both runs for the Orioles, who have lost two straight after winning nine of their previous 11. Baltimore (83-51) leads the Tampa Bay Rays by 1 1/2 games in the American League East.
Corbin Carroll, Gabriel Moreno and Walker each had two hits for Arizona, which pulled even with the San Francisco Giants in the race for the National League's third wild-card berth.
Gunnar Henderson and O'Hearn had two hits apiece for the Orioles.
After Baltimore scored in the top of the first, the Diamondbacks quickly answered.
Ketel Marte led off with an infield single and Gurriel followed by swatting Cole Irvin's changeup over the fence in left-center. It was Gurriel's 21st homer of the season, matching his career best.
Five innings later, Arizona's Tommy Pham hit a leadoff double and Walker pounded Irvin's curveball for a homer to left, giving the Diamondbacks a 4-1 lead. It was the 29th home run of the season for Walker, who first reached the majors with the Orioles in 2014.
Baltimore scored a run in the eighth inning off Kevin Ginkel as Henderson hit a one-out double and scored on O'Hearn's ground-rule double with two outs.
Cedric Mullins led off the Orioles' ninth with a single off Sewald and stole second. Sewald then struck out Jordan Westburg and Adam Frazier before retiring Ramon Urias on a grounder to third to end it.
Irvin (1-4) gave up four runs and eight hits over 5 2/3 innings. He struck out four and walked one.
O'Hearn's two-out hit in the first off Davies scored Henderson from second.
—Field Level Media