Baltimore Orioles' Robert Andino hits a three-run home run off Boston Red Sox's Clay Buchholz in the fourth inning of a baseball game at Fenway Park, in Boston, Sunday, May 6, 2012. (AP Photo/Steven Senne)

BOSTON (AP) Chris Davis had a much better day as a designated pitcher than as a designated hitter.

In the first major league game since 1925 in which both teams put a position player on the mound, Davis overcame an awful day at the plate by pitching two scoreless innings and getting the win as the Baltimore Orioles outlasted Boston 9-6 Sunday in 17 innings.

Davis went 0 for 8 as the DH, striking out five times and grounding into a double play. Yet in a season full of surprises for the Orioles, the first baseman by trade delivered the biggest one yet in his pro pitching debut.

''I was like 'Sweet! I get to try something different today - because hitting ain't working,'' Davis said. ''Basically, that was my first thought.''

Adam Jones hit a three-run homer in the top of the 17th off Darnell McDonald, an outfielder the Red Sox turned to once their bullpen was empty.

Boston then got two runners on to start the 17th against Davis (1-0). With a fastball in the mid-80s mph, he struck out All-Star slugger Adrian Gonzalez and got McDonald to ground into a double play to end a game that took 6 hours, 7 minutes.

The last time two teams brought in position players to pitch in the same game was Oct. 4, 1925, when Hall of Famers Ty Cobb of Detroit and George Sisler of the St. Louis Browns closed out the second game of a doubleheader on the last day of the season, STATS LLC said.

The last time any position player wound up as the winning pitcher was May 25, 2011, when Philadelphia infielder Wilson Valdez threw one scoreless inning in a 19-inning victory over Cincinnati.

''I was just out there trying to throw strikes and not blow the game,'' Davis said. ''In a game like that when everybody's battling, trying to get a win, both teams are throwing everything they got at each other. You don't want to blow it.''

Baltimore and Boston each used eight pitchers before going to Davis and McDonald.

''Just when you think you've seen it all, some days you come out here and just assume the position. That was fun,'' Baltimore manager Buck Showalter said. ''It was a long day, but you like to get something good out of it.''

J.J. Hardy had a career-high five hits, including two homers, as Baltimore completed its first sweep at Fenway Park since 1994 and won its fifth in a row. The shortstop also made a relay to the plate that cut down the potential winning run to end the 16th.

Robert Andino hit a three-run shot for the Orioles, who improved to a major league-best 19-9.

Boston has lost five straight. McDonald had scored the tying run as a pinch runner in the eighth, and took the final swing against Davis.

''He had pretty good stuff. He had a lot of life on his balls - more than I expected,'' McDonald said. ''I don't know what was worse - giving up the three-run home run or grounding into a double play to end the game.''

Said Red Sox manager Bobby Valentine: ''He tried to throw it over and got hit out of the park.''

''I wish there was another option,'' he said.

Boston rookie Will Middlebrooks hit his first major league homer, a grand slam that tied it at 5 in the fifth inning. Gonzalez finished 0 for 8.

Davis was having a tough day when Showalter told him to go to the bullpen and begin warming up.

''I waited as long as I could to even break it to Chris,'' he said. ''You don't put somebody in that position. It's like asking somebody if they want to walk somebody or not. It's not their decision, it's yours.''

The first batter Davis faced was Jarrod Saltalamacchia, who struck out. After Middlebrooks flied out, Marlon Byrd reached on an error by third baseman Wilson Betemit.

Mike Aviles followed with a double, but Byrd was thrown out at the plate. Jones ran down the ball in left-center field and threw a strike to Hardy, and his relay was in time as Byrd barreled into catcher Matt Wieters.

McDonald, who pitched one inning last year in his pro mound debut and gave up two runs, took over in the 17th and walked Betemit, who was thrown out trying to steal.

Hardy doubled, Nick Markakis walked and Jones hit a drive over the left-field wall.

Boston made it 6-all in the eighth when McDonald, pinch running for David Ortiz, scored on a sacrifice fly by Saltalamacchia.

NOTES: The game was Boston's longest at home since an 18-inning win over the Tigers on June 5, 2001. ... The Red Sox placed RHP Aaron Cook on the 15-day disabled list with a left knee laceration and activated LHP Andrew Miller from the DL. ... Middlebrooks is the first Red Sox player whose first major league homer was a grand slam since Daniel Nava against Philadelphia on June 12, 2010. ... The Red Sox are last in the AL East, with the New York Yankees in fourth. This is the first time since the current division format began in 1994 that the Red Sox and Yankees were in the bottom two spots past May 1, STATS LLC said.