BALTIMORE (AP) Justin Verlander lasted only five innings against the Baltimore Orioles and walked off the mound in position to take his first loss since early July.

His struggle foreshadowed the shocking end of both the game and Houston's lengthy winning streak.

Rio Ruiz hit a two-run homer with two outs in the ninth to carry Baltimore to an 8-7 victory Sunday, snapping the Orioles' five-game skid.

Houston scored three runs in the top of the ninth to go up 7-5 before the Orioles answered in the bottom half against closer Roberto Osuna (3-3). After Chris Davis hit a sacrifice fly, Chance Sisco was at first base when Ruiz launched a 2-2 pitch over the right-field wall.

"I knew that I got it," Ruiz said. "I kind of looked in the dugout, saw everybody going crazy and I went crazy. Pretty awesome feeling."

Osuna gave up a double and a homer and hit a batter in his fifth blown save.

"The guys did a great job coming back and get the lead and expected me to get the job done," Osuna said. "Not being able to do that, it's a bad day."

Coming off a 23-2 defeat less than 24 hours earlier, Baltimore took the lead in the fifth against Verlander, the 2011 Cy Young winner and an eight-time All-Star who gave up four runs and a season-high nine hits.

Baltimore's offense exploded in the ninth against Osuna, who came in with 26 saves. The loss ended the Astros' eight-game win streak and was only their fourth loss in 22 games.

"When you're playing great baseball it seems like the losses even hurt that much more," Verlander said. "We put ourselves in a position to win; our guys did a fantastic job battling back. Just one pitch early in the game, a couple pitches that I made that were mistakes.

"But I think sometimes you've got to look at the bigger picture and understand that we're playing good baseball. Don't let this be too much of a Debbie downer," he added.

Houston trailed by two runs in the seventh and 5-4 in the ninth before striking against Mychal Givens. George Springer led off with a single and went to second when Jose Altuve beat out a bunt. Michael Brantley followed with a liner that rolled into the right-field corner. Anthony Santander fumbled with the ball and botched the throw, earning an error while Brantley ended his foray around the bases with a head-first slide.

Richard Bleier (3-0) finished the inning, and turned out to be the winning pitcher in a game that concluded a homestand that featured three losses to the Yankees and two more against Houston, including that 23-2 debacle on Saturday night.

"It was a fun way to win a game, a fun way to get out of the homestand," said Jace Peterson, who had three hits and two RBIs. "Obviously, this homestand didn't go as we wanted it to (but) to leave here with a win like that over a team like that is great."

Carlos Correa hit a three-run homer for the Astros, whose ninth-inning surge enabled Verlander to keep his five-game winning streak intact. The right-hander struck out 11 to reach double digits in a fifth consecutive outing but also gave up at least one hit every inning.

"Very unusual for him to go five innings and be out of the game, but they worked him tough," Astros manager AJ Hinch said.

4K DAVIS

Davis struck out four times to bring his total for the season to 118. With Davis leading the way, the Orioles struck out 16 times.

TRAINER'S ROOM

Astros: RHP Brad Peacock (shoulder) threw 16 pitches for Triple-A Round Rock on Saturday and was slated to throw 15-20 pitches Sunday for the same club. "We didn't want to extend him too far pitch-wise (Saturday)," Hinch said. "Just simulate a back to back, see how he feels."

Orioles: INF Renato Nunez was rested after fouling a ball off his ankle on Saturday night. X-rays were negative, but the ankle was "just really sore," manager Brandon Hyde said.

UP NEXT

Astros: Zack Greinke makes his second start with Houston in the opener of a three-game series Monday night against the host White Sox.

Orioles: A seven-game road trip begins Monday with a day-night doubleheader against the New York Yankees, who have won 12 straight against Baltimore.