Updated

Steve Pearce delivered a go-ahead two-run double in the bottom of the eighth inning to lift the Baltimore Orioles to a 6-5 victory over the Boston Red Sox in the second tilt of a three-game set at Camden Yards.

Despite the loss, Boston secured the top seed in the AL and home-field advantage throughout the playoffs after Oakland lost in Seattle earlier on Saturday.

"We would have liked this game to finish up a little bit differently, but to know going into the postseason that for every series that we go into with that home-field advantage, being able to play in front of Fenway fans and how comfortable and successful we've been at home, this is a good thing," Red Sox manager John Farrell said.

Pearce finished with three RBI and Brian Roberts added a solo homer for the Orioles, who have won three of their last four games.

"He's a pro, that's why every body respects him so much," Orioles manager Buck Showalter said of Pearce. "He's always willing to do what's best for the team."

Kevin Gausman (3-5) spun 1 1/3 flawless innings in relief to pick up the win, while Jim Johnson worked around a two-out single in the ninth to nail down his 49th save of the season.

David Ross drove in two runs and Dustin Pedroia collected three hits, an RBI and a run scored for the Red Sox, who will host the winner of Wednesday's AL Wild Card Game in Game 1 of the ALDS.

Junichi Tazawa (5-4) was tagged with the loss after serving up back-to-back singles prior to Pearce's go-ahead double.

Jonny Gomes and Daniel Nava stroked back-to-back run-scoring singles in the seventh to give Boston a 5-4 edge, but Matt Wieters and Danny Valencia opened the home half of the eighth with consecutive base hits off Tazawa.

Franklin Morales entered from the bullpen and fanned Nick Markakis, but Pearce cleared the bases with a double to left to put the O's in front for good.

Early on, Pearce provided the home team with a 1-0 lead with an RBI double in the second before Roberts led off the third with a blast to left.

Roberts misplayed a Ross pop up in the fourth that allowed Boston to trim the margin in half before Pedroia punched a single up the middle in the fifth to score Stephen Drew, who doubled in front of Pedroia's base hit.

Wieters and Valencia laced back-to-back RBI singles in the home half to restore Baltimore's one-run edge, but Ross ripped a run-scoring double with one out in the sixth to even the score.

Game Notes

The Orioles have a 10-8 edge on the Red Sox this season ... Boston starter Jon Lester allowed four runs on nine hits and two walks over five frames ... Wei- Yin Chen made the start for Baltimore and was charged for three runs on nine hits over 5 1/3 innings ... Boston went 4-for-13 with runners in scoring position and left nine men on base.