Ubaldo Jimenez started strong for the Orioles but faded in the seventh when he allowed three of his four runs. He gave up a season-high 10 hits with five strikeouts and one walk over seven innings.
The Astros pulled within 4-2 in the seventh on a grounder by Preston Tucker that scored George Springer. Gattis tied the game on a two-run homer to left-center. After Brad Bach (3-0) pitched a perfect eighth, Davis got his first multi-homer game in more than a year with a towering shot to center off Tony Sipp (2-2).
Zach Britton picked up his 12th save for Baltimore.
The game was delayed 1 hour, 11 minutes at the start because of rain.
The Astros took a 1-0 lead in the second on a one-out double by Chris Carter after Gattis and Rasmus led off the inning with consecutive singles.
The Orioles took control with four runs in the fourth off right-hander Collin McHugh. Baltimore tied it when Paredes led off with a double, took third on a bunt single by Adam Jones and then scored on a double steal. Davis hit a two-run homer to right and Pearce followed with a solo shot.
McHugh allowed four runs and a season high-tying nine hits with five strikeouts over six innings.
Astros: RHP Brett Oberholtzer (blister) was scheduled to pitch five innings in a rehab start for Triple-A Fresno on Wednesday.
Astros: Lance McCullers will make his second start after picking up his first major league win against Detroit on May 23. The right-hander will face White Sox LHP Carlos Rondon.
Orioles: Two rookies who recently won their first major league decisions will start for Baltimore in Thursday's doubleheader against the White Sox. Tyler Wilson will start Game 1, while Mike Wright will get the ball in the second game. The double-header is a makeup from games postponed because of the riots in Baltimore.