The deal comes just before the team starts training camp on Thursday.
Multiple media outlets reported that the 21-year-old native of the Czech Republic gets some form of a no-movement clause as well.
Pastrnak had a career year last season with 34 goals and 36 assists in 75 games, making him the second-leading scorer behind Brad Marchand.
Pastrnak had finished his entry-level contract that had a cap hit of $925,000. The Bruins took him with the 25th pick of the first round in the 2014 draft.