The team announced the deal with the restricted free agent on Friday. It has an average annual value of $1.5 million.
Hagel, who turns 23 on Aug. 27, used his high motor to earn regular minutes with the team last season. He finished with nine goals and 15 assists in 52 games.
"Brandon's ascension to a regular role last season provided a huge boost to our team," general manager Stan Bowman said in a release. "We were quite pleased with the growth he showed in his game and ability to handle tougher assignments. His continued development at this level will allow him to be a valuable contributor to our offense moving forward."
Hagel was selected by Buffalo in the sixth round of the 2016 draft. He made his NHL debut with the Blackhawks on March 11, 2020.