Coming in, the Sox had scored three runs or fewer in 12 of their last 14 games. In this one, they already had four on the board by the third inning.
"Yeah, very good offensive night," said manager John Farrell. "Number of walks. We were able to build inside of some innings where we were able to score multiple runs. The middle of the order did an outstanding job."
After starting a 10-game road trip by losing five of the first six, the Sox closed by taking three of the last four to finish 4-6.
That included taking two out of three in the Bronx to get within six games of the first-place Blue Jays for the first time since June 1.
"I didn't even know how many games out we were honestly," said John Lackey, who grinded through five innings to get the win. "We've got a long way to go."
Red Sox No. 5 prospect Mookie Betts made his Major League debut, belting his first Major League hit while also adding a walk and a run scored.
"Just be in my approach, swing at good pitches," said Betts. "If it's not, then take it. Again, I go and relax. It's the same game I've been playing the whole time. Not wanting to put any extra pressure on myself today, so I think I did that pretty well."
David Ortiz launched career home run No. 450, a three-run shot in the third.
"Just another homer for now. I'll be counting later," said Ortiz, who is 37th on the all-time homer list and just two behind Red Sox legend Carl Yastrzemski.
Dustin Pedroia had a three-hit game while also making a couple of dazzling plays on defense. Though he's had an unspectacular season so far, Pedroia has been known to go on torrid hot streaks.
The second baseman had six hits over the final two games in New York.
"Just play the game," said Pedroia. "We're trying to win games. I'm not really concerned about me."
Mike Napoli, the Yankee killer, added a pair of hits and a walk.
"They were great tonight for sure," said Lackey. "We swung the bats great, fun way to end the road trip."
Lackey labored, but it wound up being enough. The righty went five innings, giving up six hits and five runs, four of them earned. He walked one and struck out two.
"It was a long, kind of tough road trip and it makes a late-night plane ride a little bit better," said Lackey.
The Boston bats got rolling early. Napoli opened the second with a double to left and Stephen Drew delivered a one-out RBI single to give Boston a 1-0 lead.
Ortiz took one powerful swing in the third and launched a three-run homer into the bleachers in right-center.
"If you're going to be good, your good guys have got to be good," said Lackey. "To get to where we want to be, those guys are going to have to drive the bus, for sure. You can put whatever parts around those guys and we need the parts to do well, too, but they're kind of the engine that runs this thing."
Brock Holt (walk) and Pedroia (single) set up Big Papi's moonshot, which gave Lackey a 4-0 lead.
"I just got away from myself a little bit and made some mistakes there, and I paid for it," said Yankees starter Chase Whitley. "I can't do that. It's most frustrating, obviously, with Ortiz and the walk to [Jackie] Bradley [Jr.] to start the fifth. It was unacceptable."
For Boston, the cushion turned out to be a good thing on a night Lackey didn't have his best stuff. Derek Jeter's RBI single in the third put the Yankees on the board.
In the fourth, Betts created some excitement with his first Major League hit, a hard grounder up the middle. However, the Yankees quickly erased Betts when he was caught stealing.
Mark Teixeira and Carlos Beltran launched solo shots in the fourth, and it was a 4-3 game.
"When you're a strike-thrower, you can almost, when you're not throwing precisely, you can almost throw too many strikes," said Lackey. "Guys kind of jumped on me early in counts when I wasn't locating exactly and took advantage of it."
Ultimately, the Red Sox would open it back up.
"Oh, any time you win a series on the road, particularly where we are in the standings and who's ahead of us, these are key," said Farrell. "Despite being at the end of June, with where we're at in the standings, every series is critical for us."