The Orioles let an early three-run lead get away and the Red Sox forged a 4-4 tie in the seventh on a sacrifice fly from Stephen Drew and an RBI, fielder's choice grounder off the bat of Jacoby Ellsbury.
That was all the scoring until Baltimore got to Alex Wilson (1-1) in the 13th.
Nate McLough struck out to open the inning and Manny Machado grounded out to third.
Markakis then walked on a 3-2 pitch and moved to second on a single by Adam Jones. That brought up Davis, who sent a 1-1 offering to left field for the winning hit.
T.J. McFarland (1-0) picked up his first major league victory in his 15th career relief appearance.
McFarland, the seventh Baltimore pitcher to see action in the game, worked a perfect top of the 13th to get the win.
It was one of three marathon games played in the majors Thursday. The Chicago Cubs went 14 innings before downing Cincinnati and it took 18 innings for Oakland to defeat the New York Yankees.
Chipotle plans first price increase in 3 years
Justin Bieber crashes Drake Bell's album release party