Alexei Ponikarovsky had a goal and an assist, Matt Stajan added an empty-netter with 4 seconds remaining, and Jonas Gustavsson stopped 26 shots.
Dmitry Kulikov scored twice for Florida, and Radek Dvorak and Michael Frolik had goals early in the first period. Tomas Vokoun made 27 saves for the Panthers, who have lost three straight.
Hagman beat Vokoun with a shot at 12:26 in the third period to make it 5-4 and give the Maple Leafs, coming off a 4-3 victory in Tampa Bay on Wednesday night, their first lead of the night.
Kulikov scored on the power play at 4:07 in the third to put the Panthers up 4-3, but Kessel again tied the game 13 seconds later with his eighth goal of the season.
Kulikov put the Panthers up 3-2 with his first goal of the night at 8:11 in the second period. Nathan Horton fed the puck to Kulikov, and he sent a slap shot by Gustavsson to snap a 2-2 tie. But with 5:27 left in the second, Ponikarovsky tied the game again with a power-play goal.
The Maple Leafs had evened the score at 2 with Hagman's first goal of the night, which came at 2:30 in the second period. Hagman took a pass from Ponikarovsky and tipped in the puck. Kessel's first goal of the night came with 7:43 left in the first period. He beat defenseman Keith Ballard then put the puck past Vokoun to make it 2-1.
Dvorak opened the scoring at 1:11 in the first period. About a minute later, at 2:04 in the first, Michael Frolik added a power-play goal to make it 2-0.
Florida assigned D Ville Koistinen to Rochester (AHL). Koistinen, who signed a two-year deal with the Panthers this summer, has appeared in 17 games for Florida this season, scoring one goal. … Panthers C Gregory Campbell, who is recovering from an upper-body injury, was scratched. … Florida's Steve MacIntyre, who was recalled from Rochester earlier this week, got in his second fight this week. MacIntyre tussled with Toronto R Colton Orr in the first period after fighting the New York Rangers' Donald Brashear on Wednesday night.