The remarkable victory means the Devils have a five-point advantage over the second-placed Giants.
New signing Jerome Leduc scored twice and Mike Forney got the other as the Giants took control of the contest.
Mark Richardson gave Cardiff hope and Sean Bentivoglio got it back to 3-2 before Joey Haddard equalised and Patrick Asselin netted the winner.
It was a devastating final period for the Giants who had hoped to cut the Devils lead to a single point.
Now Derrick Walser's men must pick themselves up immediately as they host Cardiff again in Belfast on Saturday night.
As befitting a clash between the top two teams, the game started at a frenetic pace which lasted the entire first period.
Both keepers were kept busy but it was the Devils' Ben Bowns who was beaten first as debutant Giant Leduc, signed only this week, finished with aplomb in front of goal to give the home side the lead in the 14th minute.
With 48 seconds of the period remaining, a Forney shot sneaked past the unsighted Bowns to raise the roof at the SSE Arena as the Giants snatched a two-goal advantage.
Leduc's fine start in a Giants shirt continued in the second period when he slammed in his second goal of the night to make it 3-0 on a Belfast power play.
The visitors were not daunted by that deficit and came back hard at the Giants with a number of impressive saves from Stephen Murphy keeping the three-goal margin intact.
But there was an almighty twist in the tale. The Devils struck early in the final period as Richardson arrowed the puck into the top corner of the net past Murphy.
Now it was the small but vocal contingent of fans from Wales who were making all the noise in the arena as the scoreline became 3-2 as a Bentivoglio shot was deflected into the net off Giants' player-coach Walser, setting up a tense finale.
Haddard then made it 3-3 with less than six minutes remaining.
Then, incredibly, Patrick Asselin's close-range finish completed a remarkable turnaround by the Devils in what could well have been a huge step towards the Elite League title.
Leaders Cardiff Devils came from 3-0 down to beat their main rivals for the Elite League title in Belfast.