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.

Kyle Robert Joyner, of Wroughton Drive, Hartcliffe, Bristol, has been charged with conspiracy to steal, between 10 April and 5 May.
The 22-year-old was detained on Friday following recent attacks on ATMs in the area. Seven machines have been attacked since the start of the year.
He was remanded to appear before Bristol Magistrates' Court later.

The incident in Portrush, County Antrim, happened in the early hours of Sunday, 26 June 2011.
It was captured on CCTV, during which the man hit the woman a number of times with the bar.
Another woman appeared to join in the assault.
The Police Ombudsman's Office said the footage shows a police car containing two officers stopping in the middle of the road close to the assault.
It said an officer got out of the car and approached the man. He dropped the bar and was then punched three times to the head by the officer before being arrested.
Police referred the incident to the Police Ombudsman's Office for independent investigation after another officer became concerned at the level of force used by their colleague.
During their investigation, Police Ombudsman investigators viewed the CCTV footage and obtained all relevant police documentation.
The Police Ombudsman, Dr Michael Maguire, noted that the CCTV footage was inconclusive as to whether the man did strike out first, as claimed by the officer.
However, he said the footage did clearly show that the man was "involved in previous fighting" and had committed a serious assault on a woman.
He indicated that as the man did not provide a statement, there was no evidence to refute the officer's account.
"Man A was subjecting a defenceless female to a serious assault," Dr Maguire said. She was in considerable danger and there is no doubt immediate action was required to prevent her sustaining further injuries or worse."
He concluded that the force used by the officer was "proportionate in the circumstances" and made no disciplinary recommendations.
A file was also submitted to the Public Prosecution Service, which directed that the officer should not be prosecuted in relation to the incident.
Leaders Cardiff Devils came from 3-0 down to beat their main rivals for the Elite League title in Belfast.
[NEXT_CONCEPT]
A man has been charged in connection with cash machine explosions in Bristol and North Somerset.
[NEXT_CONCEPT]
The Police Ombudsman has concluded a police officer was justified in punching a man who had subjected a "defenceless" woman to a beating with what appeared to be a metal bar.