It marked the first time the Yankees have made a trade with Boston since 1997, when they acquired catcher/first baseman Mike Stanley.
"It is a unique set of circumstances," Yankees general manager Brian Cashman said of making a trade with the Red Sox. "One of our two teams has to be in the playoff mode, in my opinion, and the other has to be rebuilding to some degree."
The Yankees also completed another deal before the deadline, acquiring infielder Martin Prado from the Arizona Diamondbacks in exchange for minor leaguer Pete O'Brien and either cash or a player to be named later. Prado is expected to play regularly in right field, making Ichiro Suzuki's future role with the team uncertain.
Drew was the fifth member of the Red Sox to be dealt ahead of Thursday's non-waiver trade deadline, joining pitchers Jon Lester, John Lackey and Andrew Miller and outfielder Jonny Gomes in the mass exodus from Boston.
Cashman said he tried to trade for Lester and David Price.
The Yankees had looked into signing Drew as a free agent the past two offseasons but were unsuccessful.
With Derek Jeter at short and Chase Headley at third, Drew figures to see most of his playing time at second in place of Brian Roberts. The Yankees are releasing Roberts, who hit .237 in 91 games.
Cashman said both trades came together during the final hour of the non-waiver deadline.
"I floated a text [Red Sox GM] Ben Cherington's way," Cashman said. "We worked very quickly off of that."
Drew hit .253 for the World Series champion Red Sox last year but did not accept a $14.1 million qualifying offer. He re-signed with Boston on May 22 for $10 million and has hit .176 with four homers and 11 RBIs in 39 games.
"We believe in Stephen's abilities," Cashman said.
Cashman said Drew could be a possibility to replace the retiring Derek Jeter at short next season.
Cherington said he had no reservations about making a trade with the rival Yankees.
"Given the circumstances, we hope it helps them," Cherington said. "I like Stephen, we all like Stephen. He is a good player, it hasn't worked out the way any of us wanted it to, certainly not the way I wanted it to. Hope it works out for him there, and the Yankee thing wasn't an issue in that particular conversation."
The 30-year-old Prado was hitting .270 with five homers, 17 doubles, 42 RBIs and 44 runs for the Diamondbacks this season. He also has played with Atlanta during his nine MLB seasons.
Cashman praised Prado for his versatility. Besides outfield, he can play second and third base, as well, which will give Cashman and manager Joe Girardi flexibility going forward. He is signed for two more seasons for $22 million. Cashman said he had to go to ownership to get approval for the signings.
Johnson, 32, is hitting .219 with six home runs and 22 RBIs this season, his first with the Yankees. He is currently on the disabled list.
Cherington said the Red Sox were motivated to move Drew in part to allow Xander Bogaerts to move back to shortstop and make room for Will Middlebrooks at third base.
"As the focus shifted over the past few days towards listening to trades on our veteran players, one of the things and really that coincided with a conversation we started with [manager] John [Farrell] and certainly in the front office about let's be honest about where we are no matter how we think the team should be playing or could play over the last 60 games or so, the math is against us and if we are really serious about building another team and being as good as we can as quickly as we can, what do we need to find out the rest of the way to do that," Cherington said. "One of the things we wanted to do if we could was find a way to let [Bogaerts] go back to short and give him an opportunity to play there a lot the rest of the way and give Middlebrooks the opportunity to come up and play a lot at third. Both those things will happen partly as a result of the Drew trade, not that other guys won't be in the mix at those spots, too. That was one of the things we wanted to try and accomplish the rest of the way."
ESPNBoston.com's Gordon Edes and Kyle Brasseur, ESPN Insider Buster Olney and The Associated Press contributed to this report.