BALTIMORE -- Ryan Flaherty came off the bench to replace an injured Chris Davis and had two hits and two RBIs, leading the Baltimore Orioles to a 7-6 victory over the Boston Red Sox in the final regular-season game Sunday.
Boston still finished with the best record in the American League, guaranteeing it home-field advantage throughout the playoffs. Boston will host Game 1 of the American League Division Series on Friday.
Baltimore finished 12 games behind the Red Sox in the American League East and won four of six in its final homestand of the year.
Boston center fielder Jacoby Ellsbury went 2-for-5 and hit his ninth home run of the season. Right fielder Quintin Berry got his first home run of the season for the Red Sox. Mike Napoli went 2-for-4 with an RBI.
The Orioles got two hits from rookie Jonathan Schoop, who could enter spring training as the starting second baseman. J.J. Hardy and Nate McLouth also had two RBIs apiece for Baltimore.
Davis had to leave the game in the fourth inning with a sprained left wrist.
Boston manager John Farrell held several regular starters out of the lineup, including Dustin Pedroia, Shane Victorino, Stephen Drew and Daniel Nava. Also, Allan Webster replaced John Lackey as the starting pitcher.
Webster did not allow a run or a hit over three innings. He also struck out two and walked three on 49 pitches before being replaced by Felix Doubront, who struggled in his brief appearance.
Orioles starter Chris Tillman fell short in his bid to become the club's first 17-game winner since Mike Mussing went 18-7 in 1999. He allowed five runs (four earned) on eight hits with five strikeouts and two walks over five innings.
The Orioles erased a 5-0 deficit in the fifth, tying the game on doubles by Hardy and McLouth and a single by Flaherty off Doubront, who hurt his chances of earning a spot on the postseason roster by allowing five runs on five hits in just 1 1/3 innings.
Baltimore took its first lead in the sixth on a wild pitch by Matt Thornton that allowed Schoop to score from third. Flaherty then provided a two-run margin with an RBI double to right.
The Orioles' bullpen then held the lead with Jim Johnson getting his 50th save, best in the American League, despite allowing an RBI single to pinch hitter Napoli in the ninth. Johnson got Will Middlebrooks to ground into a double play to end the game with the tying run on third.
Ellsbury led off the game with a deep home run to center. It was the 10th leadoff homer of his career and third this season. Boston extended the lead to 2-0 later that inning on a grounder by Mike Carp.
The Red Sox increased the lead to 4-0 on Berry's two-run shot in the second.
After loading the bases with three walks in the first, Webster retired eight consecutive batters before being replaced by Doubront.
Boston took a 5-0 lead in the fourth on a throwing error to first by Orioles catcher Steve Clevenger. The ball ricocheted off Davis' wrist and he was forced to leave.
Notes: Davis, who led the major leagues with 53 homers, was named the team MVP prior to the game. ... Baltimore CF Adam Jones was held out of the lineup because of soreness in his right wrist and shoulder. ... With a single in the first, David Ortiz got his first hit in 15 at-bats against Tillman. ...Boston catcher Jarrod Saltalamacchia extended his hitting streak to a career-best 11 games.