Chien-Ming Wang needed 48 pitches to get through the first two innings, but he settled in and found a way to get through the seventh.
Jason Giambi brought home the winning run with a bases-loaded walk.
With the Red Sox down to their final four outs, Melky Cabrera made a leaping catch in the eighth, robbing Manny Ramirez of a game-tying home run.
"Probably as good a catch as I've ever seen," said Bernie Williams, who homered earlier in the game. "Given the situation of the game and just how valuable his play was in the outcome of the game, it was as good as I've ever seen."
"We needed every bit of everybody's effort," said manager Joe Torre. "It was a good game. That game could have gone either way."
The Yankees now hold a 1 1/2-game lead over the Red Sox in the American League East, marking their largest lead of the season.
Despite severe injuries to Gary Sheffield and Hideki Matsui, as well as minor ones to Derek Jeter (who sat out for the second straight game on Tuesday), Giambi, Alex Rodriguez and Jorge Posada, the Yankees are now a season-best 13 games over .500, thanks largely to the contributions of such youngsters as Cabrera and Andy Phillips.
"I've been on a lot of championship teams that have gone through this kind of adversity," Williams said. "This year in particular, we have so many guys that are key to the club going down, that the guys that are coming up are picking up the slack and getting the job done. It's a sign of a good team."
"These kids come up here on this stage and play the way they've been playing, it's something that nobody can take away from them," Torre said. "They'll probably stumble a time or two during the season, but it's something they can always go back to, help them get through whatever slump they may have to fight off."
Boston rookie David Pauley, making his second big-league start, held the Yankees to two runs over 6 2/3 innings. Wang countered with seven frames of one-run ball, handing the lead over to Kyle Farnsworth and Mariano Rivera, who recorded his 12th save.
David Ortiz put the Red Sox out front in the third, blasting a Wang changeup off the facade of the upper deck in right field.
Williams tied the game in the fifth, belting Pauley's first pitch of the inning over the wall in right-center field. The crowd, which has cheered wildly for Williams with every opportunity this season, demanded a curtain call.
"Every time I get an opportunity to do that, it's very welcomed," Williams said. "Just the intensity of the game and the low-scoring game, I'm glad I had something to do with it."
Wang, who had thrown 64 pitches after three innings, tightened up with a seven-pitch fourth. He followed that with a nine-pitch fifth and a 10-pitch sixth. After putting another zero on the scoreboard in the seventh, Wang and the Yankees received a gift from the Red Sox.
With two outs in the bottom of the inning, Pauley got Miguel Cairo to hit a slow roller to the pitcher's left. Pauley couldn't handle the ball, which then headed for Mark Loretta at second. Loretta tried to barehand the ball but couldn't come up with it, extending the inning on the single.
Johnny Damon followed with a single and Cabrera walked, bringing Giambi to the plate. Rudy Seanez was summoned from the bullpen, but Giambi worked a walk on six pitches, forcing Cairo home to give the Yankees a 2-1 lead.
"With two out, anything can happen," Cairo said. "We got a little rally, and we got to score. Jason had a real good at-bat."
"He has such presence at the plate and such a great eye," Torre said of Giambi. "For a guy who hits a lot of home runs, he doesn't swing at many bad balls."
With Loretta, Ortiz and Ramirez due up, Farnsworth came in to start the eighth. He got Loretta to fly out and struck out Ortiz, leaving just Ramirez in his way to passing the ball to Rivera. Ramirez smoked Farnsworth's 1-0 pitch to left-center, where Cabrera followed it to the wall.
Cabrera leaped and brought the ball back into the ballpark, sparking an instant celebration by Damon, who was standing about five feet away.
"I don't get excited too much, but that was definitely worth it," Damon said. "That ball should have been a home run, but the wind -- the ghosts, whatever -- definitely helped us out. We need them to help us out a little."
"Sometimes you have 405-foot outs and sometimes broken-bat five-foot hits -- it pretty much evens out," Farnsworth said. "It's a great play. He saved the game for us right there."
Ramirez stood on the field and smiled. What else was he to do?
"Manny said, 'Hey you got to let that ball go out,' " Cabrera said through a translator. "I said, 'No, I've got to try to win.' ... It was important, because we needed this game and wanted this game to stay on top of them."