The deal is worth $2.35 million per season, a source told ESPN.com.
Raffl, 27, has appeared in all 61 games for the Flyers this season, tallying eight goals and nine assists. He would have been an unrestricted free agent July 1.
The Austrian-born player has 38 goals and 29 assists in 196 games played since being signed by the Flyers in May 2013.
The signing came a day before the NHL trade deadline. Raffl was a candidate to be dealt if contract talks fell through.
The Associated Press contributed to this report.