The Stars had been talking to Jagr's camp for three weeks about a possible extension, but over the past few days had second thoughts as the team faded in the standings.
Dallas received forwards Lane MacDermid and Cody Payne, along with a conditional second-round pick in the 2013 draft.
The pick will become a first-round selection if Boston advances to the Eastern Conference finals in this year's playoffs.
"Jaromir Jagr produced as a consistent scorer for our team all year, and we would like to thank him for his contributions to our hockey club," Stars general manager Joe Nieuwendyk said. "With our eye to the future, we have acquired some valuable assets that we believe strengthen our organization."
"He was the best for a long time, and he's still one of the best right now," said Krejci, who was just 4 years old when Jagr made his NHL debut with the Pittsburgh Penguins in 1990. "It's good to see him still do well at his age. I had posters of him when I was a kid. He was obviously my hockey idol."
Jagr will wear No. 68 for the Bruins and is scheduled to join the team Wednesday.
In 34 games with the Stars this season, Jagr had 14 goals and 12 assists for 26 points. That would put him fourth on the Bruins in scoring, behind Patrice Bergeron (31 points), Brad Marchand (28) and David Krejci (28).
"He wants to win," Bruins general manager Peter Chiarelli said of Jagr. "His game is still a strong power game. He was leading [Dallas] in scoring, and you watch him play and you see a lot of what you used to see in him, so I'm confident Jaromir will accept any role he's given. And he knows he's coming to a strong group and he'll help us out."
Bruins team president Cam Neely said Jagr likely won't be on the team's top line.
"I would assume that he may start on a different line than [the top line]," Neely said in a radio interview, "but you never know how things will shake out. We'll have 13 games after tonight, and we'll see what makes the best fit and gives us the best chance to get production from all three lines."
Bruins coach Claude Julien could insert Jagr on the team's third line right away, along with Rich Peverley and Jordan Caron. Once Chris Kelly -- who's out with a broken left tibia -- returns, a possible line of Jagr, Kelly and Peverley could be a strong combination for the Bruins, with speed and playmaking ability.
"We'll have to see where he fits in," Chiarelli said. "Obviously, there's a need on the third line, but he's got a higher-line pedigree. What I said to Jaromir was: We pride ourselves on four strong lines, and he's an important part, but not the part to success. So he could be on the third line. There's been times when our fourth line has been our third line, and vice versa, so it depends on who's going. We'll try to even it out, and he seemed very receptive to that."
One place Jagr should help is on the Bruins' power play. Boston is ranked 24th in the NHL in power-play percentage at 15.2 percent (14-for-92). Jagr has scored six power-play goals this season with the Stars.
ESPNBoston.com's Joe McDonald contributed to this report.