The deal is worth $5.1 million per year, Flyers president of hockey operations and general manager Chuck Fletcher said. It comes 11 days before the NHL trade deadline.
"Rasmus is an important part of our team and we are very happy to have him on our blue line for the next five years," Fletcher said in a statement. "He is committed to being a Flyer and brings a consistent physical presence to our team."
The 6-foot-4 Ristolainen is in his first season with the Flyers and has two goals and 11 assists in 49 games while averaging 21:22 of ice time. He leads the team with 177 hits, which ranks third among NHL defensemen, and has 90 blocked shots.
"I'm very happy, and I really wanted to stay. It's a great feeling to have it done before the deadline," the 27-year-old Ristolainen said. "I love this city. I love the fans. I love my teammates, and I want to be here when we turn it around next year."
Ristolainen was acquired in July in a trade with the Buffalo Sabres in exchange for the Flyers' first-round pick (13th overall) in the 2021 draft, the Flyers' second-round pick in the 2023 draft and defenseman Robert Hagg.
The Finnish player was the eighth overall pick by the Sabres in 2013. He has 48 goals and 210 assists in 591 regular-season games.