Like the Panthers, the Flames will miss the Stanley Cup Playoffs, but Calgary is 11-9-0 since the break for the 2014 Sochi Olympics.
"It's a big win," Flames coach Bob Hartley said. "I don't care that we're not making the playoffs, I don't care that we're at the end of the season. It's an investment. We're asking the guys to play playoff hockey and I think we showed that tonight."
Luongo, who missed the previous three games because of a concussion, finished with 15 saves in his 800th NHL game. He joined Martin Brodeur of the New Jersey Devils as the only active goalies to have reached that number.
Luongo hadn't played since being injured against the Carolina Hurricanes on March 27.
"I felt a hair off as far as my game is concerned, but I only had one practice (Thursday) and jumped right into the game," Luongo said. "It will get better as a couple days go by."
Vincent Trocheck scored for the Panthers, who have lost eight of nine. They have scored 13 goals in the eight losses.
Calgary, which finished a two-game season sweep of Florida, is 2-2-0 on a five-game road trip that ends Monday against the New Jersey Devils.
MacDonald was making his first start since March 14 after Karri Ramo was in net for the previous six games, including a 4-1 victory against the Tampa Bay Lightning on Thursday.
"They got a lot of pucks to the net," MacDonald said. "They got a few good shots, but I saw most of them. We got in some trouble early in the first period. We kind of got hemmed in a little bit, but we kind of kept him to the outside and I took care of the rest."
"That's kind of the way that things have been going here the last few months," MacDonald said. "Guys just dive in front of pucks. That's why we've been winning, sacrificing the body. As a goaltender, you love seeing that."
Agostino, one of two players acquired in the trade that sent Jarome Iginla to the Pittsburgh Penguins last March, was playing in his fifth NHL game after wrapping up his senior season at Yale University. He had been a healthy scratch for Calgary's previous three games.
He scored 1:34 into the second period after jumping on a loose puck at the top of the left circle and firing a wrist shot that beat Luongo to the blocker side.
"It was kind of a broken play and the puck just came to me," Agostino said. "Unforgettable feeling when it went in. Yeah, I was going [for that corner]. Luckily, I was able to get it past him."
Trocheck tied it 47 seconds later with a rare power-play goal for the Panthers. After MacDonald stopped Jimmy Hayes' wrist shot from the wing, Trocheck put home the rebound from the slot.
Florida came in with the worst power play in the League (10.1 percent).
"We definitely had the chances tonight," Trocheck said. "I thought we played pretty well all around. I guess the puck just wasn't going in for us. We had the chances for sure; we just have to bear down on those chances."
Cammalleri gave Calgary a 2-1 lead at 6:09 with some hustle and a feed from Jiri Hudler. Cammalleri fell to his knees firing a shot that was deflected wide but quickly got up and skated to the side of the net, where he redirected Hudler's cross-ice pass.
Cammalleri has scored the game-winning goal in six of Calgary's past eight victories.
"[Hudler] sees it as good as anybody," Cammalleri said. "You've just got to try and find spots when you're on the ice with him and he's got the puck."
Cammalleri has 236 goals and 264 assists in a career that began in 2002-03 with the Los Angeles Kings. He has 176 points in two stints with the Flames after getting 205 with Los Angeles and 119 with the Montreal Canadiens.
"It's special to reach certain benchmarks like that," the 31-year-old said. "Whenever something like that happens, it gives you a second to reflect and appreciate what we get to do and all the people that have helped you. But I think my best hockey is ahead of me, so I look forward to many more."
Cammalleri came close to getting point No. 501 in the third period when he deked Luongo on a breakaway before the goalie got his stick on the shot into the open net.
But it was MacDonald who made the tougher saves. He also got a break in the final 20 seconds of the first period when Scott Gomez's shot from a sharp angle bounced off both posts.
"Joey is a good pro," Hartley said. "He doesn't get rattled. He's always ready. You bring him in the middle of a game, you give him a start with a day or two notice, you're sure that he's going to be ready. His positioning is very good. He's a veteran, so he understands the game. He's always in the right place at the right time and he gave us some real big saves."
Friday was the first of five consecutive home games for the Panthers, their longest season-ending homestand.
Calgary defeated Florida 4-3 in a shootout at Scotiabank Saddledome on Nov. 22.