The Red Sox overcame an early 3-0 deficit to take two out of three in the series.
Texas called on Michael Kirkman (0-2) to get through the ninth inning in a tie game, but he did not retire a batter. Jonny Gomes doubled to lead off the inning, Dustin Pedroia was walked intentionally and Ortiz then hit Kirkman's first offering over the wall in right.
The homer by Ortiz made a winner out of Andrew Bailey (2-0), who worked his way around a leadoff single in the top of the ninth.
Pedroia brought the Red Sox within one with a two-run double in the third and Boston tied it in the seventh when Jacoby Ellsbury scored from third on a fielder's choice grounder off the bat of Mike Napoli.