The deal was finalized during San Francisco's 11-3 win over Pittsburgh and announced after the game.
"It's exciting," Nunez said while standing outside of manager Bruce Bochy's office. "You're going to go [play] for a championship. That's why we're here. That's the focus right now."
Nunez, 30, won't join the Red Sox until Friday. He started at third base for the Giants on Tuesday, hit a two-run double and scored twice before he was removed for a pinch hitter in the fifth inning. The infielder, who was hit by a pitch on the left elbow earlier in the game, was shown on television shaking hands with teammates in the Giants' clubhouse.
Nunez had been on a tear for the Giants. His .348 average is the fourth highest in the majors since June 1 (minimum 100 plate appearances). He went 9-for-16 (.563) in his final four games with San Francisco.
In addition to third base, Nunez has played four other positions in his career -- second base, shortstop, left field and right field -- and has a negative defensive runs saved at all five spots.
"He's very talented, and that's why a lot of clubs wanted him," Bochy said. "He can run, he's a good hitter, he can play anywhere. I'm going to miss him because this guy was exciting. He's got a chance to get to the postseason, so I'm happy for him. He'll help that ballclub."
The Giants, who are 31½ games back of the National League West-leading Los Angeles Dodgers, also are open to trade discussions involving pitchers Johnny Cueto and Jeff Samardzija, according to ESPN's Buster Olney.
Nunez did not rule out the possibility of re-signing with San Francisco in the offseason when he's scheduled to become a free agent. For now, Nunez said he's intent on helping the Red Sox maintain their lead in the AL East.
"I never listened really the last two weeks where I was going," Nunez said. "I just focused on playing. I don't read that much Twitter and those things. I am focused on who's pitching tonight, who's pitching the next day."
The move could clear the way for the Giants to recall Pablo Sandoval from the minors, although Bochy said that's not likely to happen. The 2012 World Series MVP with the Giants, Sandoval signed a minor league contract with San Francisco last weekend after he was released by Boston, which signed him to a $95 million, five-year deal after the 2014 season.
Sandoval hit just .237 with 14 homers and 59 RBIs during two-plus injury-decimated seasons with the Red Sox. He has played for Class A San Jose and Triple-A Sacramento since rejoining the Giants organization.
"We're not going to bring Pablo here until we think he's ready," Bochy said.
Red Sox rookie Rafael Devers, 20, made his first major league start at third base on Tuesday night against the Mariners and went 0-for-3 with two walks and a run scored. General manager Dave Dombrowski said no decision has been made yet on whether Devers will stay or return to the minors.
The Associated Press contributed to this report.