Dustin Pedroia drew a leadoff walk and took second on a groundout by David Ortiz. Mike Napoli was walked intentionally and Jarrod Saltalamacchia struck out. Jonny Gomes then walked, loading the bases, and Drew hit a liner just inside the right-field line as Pedroia scored the decisive run.
Boston moved a half-game ahead of Tampa Bay in the division. The Rays lost 7-0 Wednesday night to the Arizona Diamondbacks.
Drew Britton (1-0) pitched two innings for his first major league win. Lucas Luetge (0-2) took the loss.
The Mariners threatened in the 15th when one-out singles by Raul Ibanez and Endy Chavez put runners at first and second. Michael Saunders then hit a low liner to left. Gomes charged in and made a diving catch, then ran all the way to touch second base for an unassisted double play as Ibanez had no chance to get back.
Boston wasted an excellent chance in the 14th when Brandon Snyder led off with a pinch-hit double, its first hit since the seventh, and took third on a sacrifice by Jacoby Ellsbury. But Snyder was thrown out trying to score on Shane Victorino's fly to center fielder Saunders, ending the inning.
The Mariners also threatened in the 11th and 12th but stranded two runners in each inning.
Boston's previous longest game this year lasted 14 innings, a 10-8 win over Tampa Bay on June 10. Five days earlier, Seattle played its longest game, a 7-5 loss to the Chicago White Sox in 16 innings.
Kyle Seager had tied the game at 4 in the eighth with his 17th homer of the year, a solo shot off Junichi Tazawa.
Pedroia had given the Red Sox a 4-3 lead with a two-run homer in the seventh, his eighth, after a single by Victorino.
The Mariners went ahead 1-0 in the fourth on a run-scoring double by Seager before the Red Sox took the lead with two unearned runs in the fifth.
Brock Holt led off with a double and took third when center fielder Dustin Ackley dropped Ellsbury's low liner for an error. Victorino then grounded to second baseman Nick Franklin, who may have been distracted when Ellsbury ran in front of him.
Franklin bobbled the ball for another error as Holt scored. Pedroia then grounded into a forceout at second base, allowing Ellsbury to score.
The Mariners took a 3-2 lead with two runs in the sixth. They loaded the bases on a single by Humberto Quintero, a walk to Brad Miller and a single by Seager. Kendry Morales tied it with a sacrifice fly and Ibanez put Seattle on top with an RBI single.
Boston starter John Lackey shook off a liner off his left heel by Ackley in the third. Manager John Farrell and a trainer went toward the mound, but Lackey waved them away before they arrived.
Seattle starter Hisashi Iwakuma overcame a shaky start when he gave up singles to the first three batters in the first Ellsbury, Victorino and Pedroia. But Ortiz grounded to Iwakuma, who threw home to start a double play, and the Red Sox didn't score. Iwakuma allowed just four hits in his remaining 4 2-3 innings.
NOTES: Seager went 3 for 6 and hit .396 in July (38 for 96). ... Lackey allowed at least three runs for the third straight game after giving up two or less in six consecutive starts. ... Iwakuma gave up no earned runs for his second straight outing. ... The Red Sox recalled Holt from Triple-A Pawtucket. He started in place of Jose Iglesias, who went to the Detroit Tigers on Tuesday night in a three-team, seven-player trade that brought RHP Jack Peavy to Boston. Peavy is expected to join the Red Sox on Thursday and pitch during the seven-game homestand that ends Sunday. ... Felix Hernandez (11-4) pitches for Seattle in the final of the three-game series against Ryan Dempster (6-8).