BOSTON — Most of the seats were empty late on a rainy night when the Boston Red Sox’s home sellout streak of nearly 10 years ended.

Manny Machado ruined it for the fans who remained.

His three-run homer off closer Joel Hanrahan capped a five-run ninth inning and gave the Baltimore Orioles an 8-5 win Wednesday night.

“It was a huge win for us,” Machado said after his first homer of the year. “To come out with the victory is just going to give us the big boost that we needed to get this show rolling.”

The Orioles were headed for their fourth straight loss after consecutive homers by Daniel Nava and Jarrod Saltalamacchia gave Boston a 5-3 lead in the sixth. Then Hanrahan, who was three-for-three in save opportunities as Boston’s new closer, came on in the ninth.

“I felt fine,” he said. “I got ahead of a couple of guys and I just didn’t put them away.”

Chris Davis started the inning with his fifth homer before Hanrahan, obtained in the offseason from the Pittsburgh Pirates, retired the next two batters. Then he was one strike away from winning, but Ryan Flaherty singled on a 2-2 pitch for his first hit in 18 at-bats this season. He had struck out in his other three at-bats Wednesday.

“You want to get on base and give your team a chance to win,” he said. “You never want to wait until the ninth, but it was good resilience and a good win.”

Nolan Reimold then walked on four pitches and Nate McLouth walked on a borderline pitch with a 3-2 count, loading the bases.

“There was some calmness and professionalism to those at-bats,” Baltimore manager Buck Showalter said.

On the first pitch to Machado, Hanrahan fired the ball into the dirt for a wild pitch that scored pinch-runner Alexi Casilla with the tying run. And the next pitch was Hanrahan’s last of the game — Machado’s homer over the Green Monster in left field. Hanrahan left to a round of boos.

“I probably would have given the same reception,” Hanrahan (0-1) said. “They stuck through a rain delay. They stuck it out.”

Darren O’Day (1-0) got the win and Jim Johnson pitched the ninth for his third save.

“You’ve got your closer in the game, the ballgame locked up, it’s tough,” catcher Saltalamacchia said. “But I still feel that Joel’s got some of the best stuff I’ve ever caught.”

The sellout streak began on May 15, 2003, lasted 820 games, including the postseason, and was the longest in major pro sports history. It broke the record of 814 set by the NBA’s Portland Trail Blazers from 1977-95. Boston’s streak of 794 regular-season sellouts also is the longest in major pro sports history. The previous longest regular-season streak in major league baseball history was 455 set by the Cleveland Indians from 1995-2001.

Nava gave the Red Sox a 4-3 lead with his third homer in three games, an opposite-field shot over the Green Monster. Saltalamacchia followed with his first homer, a hard shot over the right-field fence.

Baltimore took a 1-0 lead in the first with the help of Boston’s first error of the season. McLouth walked before Machado hit a fly ball to right-center. Center fielder Jacoby Ellsbury and right fielder Shane Victorino converged on it. Victorino ducked in front of Ellsbury and the ball fell safely. Victorino was charged with the error during the game, but the error was later given to Ellsbury after manager John Farrell said Ellsbury had called for the ball late.

Machado moved to third on the play and scored on a groundout by Nick Markakis.

The Red Sox tied it in the second on a walk to Nava and an RBI-double by Saltalamacchia. They went ahead 3-1 in the third when Jackie Bradley Jr. led off with a walk, Ellsbury tripled him home and Victorino hit a sacrifice fly.

Another error helped the Orioles tie the game in the fourth. Markakis started the inning with his first homer of the season. Adam Jones then walked, extending his hitting streak to all eight games, and moved up on a wild pitch. Matt Wieters then singled to left and Jones scored when the ball eluded Bradley.

NOTES: The game was delayed by rain for 43 minutes after the fifth inning with the score 3-3. … Reimold returned to the lineup after leaving Sunday’s 4-3 loss to the Minnesota Twins with a strained right hamstring. … There was a moment of silence before the game for Dave O’Hara, the former New England sports editor for The Associated Press in Boston, who died Wednesday at the age of 86. … The Red Sox activated SS Stephen Drew from the seven-day concussion disabled list, optioned SS Jose Iglesias to Pawtucket and called up RHP Alex Wilson from that Triple-A team. … The Orioles traded RHP Luis Ayala to Atlanta for LHP Chris Jones. Jones was assigned to Double-A Bowie. Baltimore purchased the contract of OF Chris Dickerson from Triple-A Norfolk.

Only subscribers are eligible to post comments. Please subscribe or to participate in the conversation. Here’s why.

Use the form below to reset your password. When you've submitted your account email, we will send an email with a reset code.