Ben Chiarot scored for Detroit (21-21-5), which has lost four of its past five (1-3-1). Alex Lyon made 24 saves.
Ristolainen's goal came after Patrick Kane had a chance at the front of the net with 38 seconds left.
"We had our 2-on-1 with 40 seconds left, they had their 2-on-1 with 20 seconds left. Unfortunately, they scored," Red Wings coach Todd McLellan said.
Farabee put the Flyers ahead 1-0 at 5:21 of the second period. Sean Couturier took a pass from Farabee and backhanded a return pass into the slot. Farabee deked and lifted a backhand over Lyon.
In three games back in the lineup since being scratched for three games, Farabee has four points (one goal, three assists). The forward had three points (two goals, one assist) in 13 games before sitting out.
"Watching my previous games before [being scratched], something I wanted to focus on, and [general manager] Danny [Briere] talked to me about, was getting to the inside and trying to make plays through the middle and not just staying on the perimeter," Farabee said. "I'm not really going out there and doing anything crazy different, but just the idea of when I don't have the puck try to get to the net and try to get on the inside, and I got a couple lucky bounces."
Couturier and Matvei Michkov, Farabee's linemates, each had an assist Tuesday, and the three of them have combined for 11 points (three goals, eight assists) the past three games.
"[Farabee] has played great," Couturier said. "He's a really smart player. When he has his confidence, he can make plays, creates a lot out there. It seems to be clicking. We've had chemistry in the past and we seem to kind of find that again lately.
"I think he's just going out and playing his game, not really overthinking it, reacting to plays. I think as a line, even with 'Meesh' [Michkov], we're finding each other pretty well and making plays. We've just got to keep building on that."
Chiarot scored 30 seconds into the third period to tie the game, beating Ersson from the left side after a backhand pass through the slot by Red Wings forward Lucas Raymond.
"It was huge," Red Wings captain Dylan Larkin said. "Especially my line [with Raymond and Marco Kasper], we didn't have the best second period, but we got out there and got on the forecheck and that was an emphasis coming in after the second. Get on the forecheck, make their [defensemen] turn and that's exactly what we did, and we got rewarded for it."