Daniele Conti had the first effort of the game on six minutes, although Torino's defence stood firm.
Andrea Cossu had another chance for the home side, but he couldn't find the target with his strike.
Cagliari were then given a chance to take the lead when the referee awarded them a penalty on 36 minutes.
Marco Sau stepped up and slotted the spot kick home to make it 1-0.
Radja Nainggolan almost doubled Cagliari's lead just before the half-time whistle, although his effort went just wide of the post.
Torino pushed forward early on in the second half and were rewarded for their bravery on 47 minutes when Alessio Cerci struck to make it 1-1.
Alen Stevanovic then put the away side in front with a great finish on 54 minutes to stun Cagliari.
Cerci threatened to extend Torino's lead soon after, but his shot was blocked well by the defence.
Cagliari drew level on 75 minutes when Cossu found Conti, who headed home to make it 2-2.
The home side were then given the chance to take a late lead on 86 minutes when Angelo Ogbonna saw red and gave away a penalty.
Mauricio Pinilla then smashed the spot kick home to make it 3-2.
Torino then went down to nine men on 88 minutes when Abou Diop was sent off by referee.
The away side were then given a golden opportunity to draw level after being awarded a penalty in injury time. Rolando Bianchi stepped up and kept his nerve to make it 3-3.
The drama wasn't finished, though, as Conti made it 4-3 to Cagliari with what was almost the last kick of the game.