It was just minutes earlier that Cogliano had a good chance in the slot but rang a shot off the outside of the post.
Finishing it off wasn't easy, however. The Flames poured on the pressure in the final minute with the goalie pulled. Mike Cammalleri's blast came the closest to getting past Jonas Hiller, but the Ducks hung on.
Nick Bonino and Mathieu Perreault also scored for Anaheim (47-18-7), which kicks off a three-game road trip to Western Canada with its sixth road win in its last eight games away from the Honda Center.
The win moves the Ducks to within two points of the San Jose Sharks and the lead in the Pacific Division. Anaheim still holds two games in hand.
Trailing 2-1 headed to the third period, the Ducks tied it at 5:32.
Sami Vatanen's rising shot from the blue-line hit a scrum of bodies in front that included Ramo, who had come out of his crease to cut down the angle. Unfortunately for the Flames goaltender, the puck dropped at the skates of Perreault, behind Ramo, and he easily slid the puck into the vacated net.
Perreault's 16th goal extends his point streak to six games (four goals, two assists).
Trailing 1-0 after the first period, the Flames tied it at 4:44 of the second. Although the goal was flukey, it came after a shift in which the trio of McGrattan, Kevin Westgarth and TJ Galiardi put in some tireless work deep in the Anaheim end.
Tyler Wotherspoon made a great play at the blue-line to keep the puck in after an attempted clear. His quick shot towards the net deflected off the glove of Kevin Westgarth in front then bounced in hit the leg of McGrattan and trickled behind Hiller.
McGrattan's fourth goal and 10th of his career comes in his 300th NHL game.
Calgary took a 2-1 lead with 26 seconds left in the second, the result of a pretty play by Ladislav Smid.
Not known for offensive creativity at all — just four assists in 71 games entering the night — Smid fooled everyone on the ice with a fake shot before sending a quick pass to Hudler at the face-off circle who blasted a slapshot past Hiller before he could get across.
It was the second time this month the two teams had met at the Scotiabank Saddledome. Two weeks ago, the Flames scored four times in the first period in routing the Ducks 7-2.
Calgary got off to a good start again Wednesday, outshooting the Ducks 12-9 in the opening 20 minutes, but this time were not able to get to Hiller.
Chased last time less than 12 minutes in, after surrendering three goals on five shots, the Swiss native went the distance this time, finishing the night with 32 stops to improve to 29-11-6.
Anaheim got the only goal of the first period on a pretty individual effort from Bonino.
After weaving his way through centre and into the Calgary zone, he ripped a shot into the top corner past the outstretched glove of Ramo.
It was the third power-play goal in three games for the Ducks, who in the nine games prior to that were 1 for 33 with the extra man.
Ramo had 31 saves to fall to 13-11-4. The Finn had won his previous five decisions.
Notes: On the eve of the one-year anniversary of the trade of Jarome Iginla to Pittsburgh, the two players they received in return - LW Kenny Agostino and RW Ben Hanowski, were both healthy scratches for the Flames... Calgary LW TJ Galiardi drew back in after missing the past two games... Not in the line-up for Anaheim were D Francois Beauchemin, C Daniel Winnik and LW Matt Beleskey... Anaheim's 22nd road victory ties the franchise record, previously done in 2006-07 and in 2008-09.