Ortiz sent the ball over the right-field wall for his 11th career walk-off homer to solidify Boston's (37-24) lead in the American League East, while Texas (36-23) allowed Oakland (37-25) to close within a half-game in the AL West.
The Athletics closed the gap with a 5-4 win over the Chicago White Sox (25-33) in 10 innings, Yoenis Cespedes hitting two homers and Adam Rosales putting another one over the wall in the 10th.
National League Central leaders St. Louis took down Arizona, top dogs in the NL West, 12-8 after Matt Adams belted a three-run homer during an eight-run fourth inning. The Cardinals (39-21) had five homers in the game.
Arizona (34-26) pitcher Ian Kennedy allowed a career-high 10 earned runs and 13 hits in just four innings.
Detroit ace Max Scherzer (8-0) remains unbeaten after throwing a four-hitter through seven innings with nine strike outs as the Tigers took down the Tampa Bay Rays 5-2.
Victor Martinez homered and drove in three runs to push the Tigers to 32-26 and drop the Rays to 32-27.
The Los Angeles Dodgers (26-33) scored a rare win against a form team, breaking the Atlanta Braves (37-23) five-game winning streak with a 5-0 shutout, while the New York Yankees (35-25) cruised to a 6-1 win over Seattle (26-35). (Reporting by Ben Everill in Los AngelesEditing by Peter Rutherford)