The Bruins and Bartkowski avoided an arbitration hearing with the deal, which is worth $1.25 million.
"It's always good if you can come to an agreement before the hearing. So I think it sends a positive message to Matt that we want to have him back," Bruins general manager Peter Chiarelli said in a statement.
Bartkowski, 26, played his first full season with the Bruins in 2013-14 and registered 18 assists in 64 games. He also had a plus-22 rating and 30 penalty minutes.
"I'm grateful to be able to sign with the Bruins organization, because I know we have a chance to win every year and I'm excited for the upcoming season," Bartkowski said.
He began the season as a healthy scratch and eventually worked his way into the lineup after Boston's blue line suffered numerous injuries.
"He's still relatively young," Chiarelli said. "I thought that when Dennis Seidenberg got hurt, he was able to come in and play some real solid minutes. He's the type of player that can really push the puck well. A lot of people remember the couple of blips in the playoffs, but he gave us very good service during the course of the year with Seidenberg out, and [defense is] a tough position in the league and there are nuances that he's still learning and I expect him to continue to improve."
The Bruins attempted to trade Bartkowski at the deadline during the 2012-13 season to the Calgary Flames in exchange for Jarome Iginla, but the deal fell through when Iginla waived his no-trade clause to play for the Pittsburgh Penguins. Iginla eventually signed a one-year deal with the Bruins last season but left the team for the Colorado Avalanche via free agency earlier this month.
Boston selected Pastrnak in the first round (No. 25 overall) in last month's NHL entry draft, and he was impressive during its rookie development camp at Ristuccia Arena last week.
"It's a great feeling, and that's why I've been practicing, that's why I'm going for it and I just have to keep practicing and get better before I make the team and before the contract's going to mean something," Patrnak said. "I want to play in the NHL now."
The 6-foot, 171-pound forward will return for training camp in September and is scheduled to play in a few preseason games, according to Chiarelli.
"He had a terrific development camp, and I know everyone's talking about him," Chiarelli said. "He's a good young player, he's just 18 years old, and he's a player. It's well-documented that we're looking for skill and speed and he fits that bill, but let's not put the cart before the horse with David. I think we're fortunate to get him where we got him and he had a terrific camp, and we'll see where it goes from there."
If Pastrnak plays well during training camp and the preseason, the Bruins have nine regular-season games to decide whether to keep him on the roster or send him back to continue his development in the Swedish Elite League.
"It's another step along the way, and it's important that we don't skip those steps," Chiarelli said. "And at each step, the level of play, the tempo of play, the strength of the players -- at least, those players are varying in strength -- all increases, so with a young 18-year-old who's 171 pounds, you have to be careful. Now, he's strong, he's naturally strong, so he's got that going for him, but we'll have to see."
At the conclusion of rookie camp Sunday, Chiarelli said Pastrnak's play stood out and that there was a chance he could earn a spot on next season's roster.
"You never know," Chiarelli said. "You don't want to place too much of a burden on this kid's shoulders, but he was good. The hesitation you have is he's 170, 173 pounds, but he's wiry strong, so you never know. Speed, skill, sense is all there, so it would be nice, but we'll see. He's young, and to throw someone like that at that age, at that weight, but there have been guys who have done it."