Mitchell Marner scored two goals, and John Tavares got his 20th goal for Toronto (21-10-2), which has lost four of five. Andersen made 29 saves, and Morgan Reilly and Jake Gardiner each had two assists.
Florida led 2-0 before Toronto came back in the third period after switching its forward lines.
"The first two periods weren't good," Babcock said. "In the third period, we took over and really got to work."
Tavares made it 2-1 at 10:24 when he tipped Gardiner's shot from the point, and Marner tied it 2-2 at 16:21 with a wrist shot from the slot.
Barkov scored 27 seconds later to give the Panthers a 3-2 lead at 16:48, but Marner tied it 3-3 at 18:20.
"We finally got some rhythm," Tavares said. "We just seemed a little flat tonight, and those are going to happen sometimes. You just have to find a way to get yourself going and keep yourself alive. In a lot of the third, we made a good push. We made a lot of good plays. Just a couple of mistakes ended up costing us."
Barkov scored on the power play to give Florida a 1-0 lead with four seconds left in the first period when he took Evgenii Dadonov's pass across the crease and shot high into an open net.
"We've been talking a lot about playing a hard 60 minutes, and I feel like we really did," Barkov said. "Of course, they tied a couple of times at the end, but we showed our character, and we came back and scored a couple more goals and won the game against a pretty good team."
Huberdeau made it 2-0 at 8:03 of the second period with another power-play goal with a wrist from just inside the left face-off dot. He has 21 points in the past 11 games.
"It's been working," Huberdeau said. "I try to play simple. I feel more confidence with the puck, obviously. It's just nice as a line to get going. We want to be a threat offensively every game, and that's what we did tonight."
Toronto was 0-for-4 on the power play. Florida went 2-for-4, extending its streak of home games with a power-play goal to 13, matching the 2017-18 Nashville Predators for longest streak in the NHL over the past 10 seasons.
"They scored on their power plays," Marner said. "We have to be better on ours. Tonight wasn't good enough, and it's something we just have to be a lot better at. It's something we can always improve on."