The Samp defender scored the only goal of the game in the 11th minute to earn the Blucerchiati the second consecutive win that lifted them into 12th place, where they are now 11 points clear of the relegation zone.
But Cagliari, who suffered their fourth loss in five league games and dropped to 15th place in the process, have not won a league game on the road since February 2013 and lie only seven points above the bottom three.
Samp took the lead by converting their first chance of the game when Gastaldello got behind Vasco Regini's cross to head the ball beyond Rossoblu goalkeeper Vlada Avramov.
Cagliari wasted a good chance to pull level in the 32nd minute when Matias Vecino picked out an unmarked Albin Ekdal in the box, only for the Swede to miss the target from a good position.
And on the stroke of half-time, Avramov made a vital save from Manolo Gabbiadini's close-range attempt.
The islanders pressed forward after the break and came close to equalising shortly before the hour mark.
Nicola Murru fed Nene in the area and the Brazilian's diagonal shot forced Samp keeper Junior Costa to dive to his right to make the clearance.
Costa was called on again eight minutes from time, on this occasion to keep out Marco Sau's shot from 12 yards, and when the final whistle blew Samp had managed to keep a clean sheet for a second match in a row.
The Genovese club next travel to the Stadio Olimpico to face second-placed Roma while Cagliari return to Sardinia ahead of their Stadio Sant'Elia meeting with strugglers Livorno.
This weekend also saw Cagliari owner Massimo Cellino move closer to selling the club he has run since 1992 as he prepares to finalise a takeover of second-tier English outfit Leeds.