The deal carries an average annual value of $2.5 million per season.
In his second stint with the Bruins, Khudobin proved to be a more than capable backup to Tuukka Rask. The 32-year-old was 16-6-7 with a 2.56 goals-against average and .913 save percentage.
Khudobin had expressed interest in staying in Boston, where he also played from 2011 to '13.
He made $1.2 million in the final year of the two-year contract he signed with Boston.
Now he heads to Dallas to back up starter Ben Bishop.
The Stars also added depth along the blue line with a deal for Roman Polak.
The Maple Leafs, who have had a need on the blue line for a while, signed the 32-year-old to two straight one-year contracts.
Polak was steady with 12 points and a plus-5 in 54 contests, mostly providing toughness to a skilled group. His salary was $1.1 million after earning $2.25 million the year before.
Polak played the first eight years of his career in St. Louis.
The Stars are also bringing back winger Valeri Nichushkin on a two-year, $5.9 million contract after their 10th overall pick in the 2013 draft spent the past two seasons playing in his native Russia.
The 23-year-old Nichushkin made his NHL debut as a teenager in 2013 and spent three years in Dallas. His two years in Russia were with CKSA Moscow of the Kontinental Hockey League, where he had 51 points (27 goals, 24 assists) over 86 games.
This past season, Nichushkin helped the club reach the KHL championship series with nine points (three goals, six assists) in 19 playoff games.
Nichushkin has appeared in 166 NHL games, registering 64 points (23 goals, 41 assists). He was on the only two playoff teams Dallas has produced in the past 10 years in 2014 and 2016.
The Associated Press contributed to report.