The hosts needed all three points from Monday night’s match to reclaim fifth place from Atalanta and Danilo D’Ambrosio’s first-half opener put them on the right track.
However, after Patrik Schick levelled, Quagliarella put away an 85th-minute penalty to keep Inter at least another win away from the nearest Europa League berth.
Antonio Candreva missed a sitter in the early exchanges and Samp soon replied with Quagliarella hitting a post with a long-range attempt.
In the 35th minute D’Ambrosio made the breakthrough after collecting Ever Banega’s pass and driving it home thanks to a heavy deflection off Bartosz Bereszynski.
Schick hit the frame of the goal just before the break and, five minutes after the restart, Samp equalised when the young Czech striker met Bruno Fernandes’ cross from the left.
The game opened up and visiting goalkeeper Emiliano Viviano kept Ivan Perisic’s header out before, at the other end, Samir Handanovic repelled Quagliarella’s angled drive with his feet.
Inter then missed a double chance with Eder causing Viviano trouble with a powerful right-footed effort before Mauro Icardi clipped Candreva’s assist over the bar.
Just when it looked like the Nerazzurri would have to settle for a point, they were denied any share.
When Samp won a penalty for Marcelo Brozovic’s handball in the box, Quagliarella converted to secure the Blucerchiati their first victory in this fixture since 1996.