Stuart, a key player in last season's deal that sent former Bruins captain Joe Thornton to San Jose, had been mentioned in recent trade talk because of his upcoming free-agent status.
Boston's inability to work out a new contract with Stuart forced the deal, completed just over an hour after the Bruins beat the New York Islanders 4-3 in a shootout.
"It became evident that when I wasn't having success signing Brad that I was going to have to trade Brad," general manager Peter Chiarelli said.
Stuart, 27, was acquired with Primeau and Marco Sturm on Nov. 30, 2005, for Thornton - who went on to win NHL MVP honours with the Sharks last season.
Boston missed the playoffs and is in danger of doing so again this year. They're last in the Northeast Division with 54 points.