Stuart, a key player in last season's trade 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 honors with the Sharks last season. Sturm has also been the subject of recent trade rumors.
The Thornton trade could go down as one of the organization's worst -- and most unpopular trades -- just like the deal that sent Hall of Fame defenseman Bobby Orr to the Chicago Blackhawks in 1976.
Boston missed the playoffs and is in danger of being left out of the postseason again. The Bruins are last in the Northeast Division with 54 points.
"When any team doesn't win hockey games something has to change," Boston coach Dave Lewis said.
Ference, 27, played in 53 games this season for Calgary. He is signed for three more seasons.
"Part of what we have to do is preserve the assets of players that are unrestricted," Chiarelli said. "Chuck is 24 and Andrew is 27. They add some youth and energy, which we want to add to this team."
Kobasew, who played on Boston College's 2001 NCAA championship team before going pro, appeared in 40 games with Calgary -- notching four goals and 13 assists.
Ference played in Buffalo on Saturday night. Kobasew has been sidelined with an elbow injury since late January.
"I'm really looking forward to it," Kobasew said in a statement released by the Bruins. "It's disappointing to leave Calgary, but I did play two years of my career in Boston; one at Boston College and one at Lowell in the AHL."
Ference was surprised to be sent away by the Flames.
"It's always a bit of a shock when you get traded," he said. "But obviously when you're traded to a storied franchise it's definitely a little easier to take."
Chiarelli hopes this trade shows he is trying to build a winner now while also looking toward the future.
"I would like to think it says that we're getting two high-character players and we have an influx of youth and energy," he said. "I don't want to send a message that we're throwing in the towel. These are players that are on a division-leading team with experience. They're good players."