Gilardino, who came on as a substitute, struck home a low drive in injury-time after some brilliant foot work from Brazilians Pato and Kaka.
Milan’s win moved them to ninth place in the Serie A table with 24 points and maintained their hopes in securing a Champions League spot.
Elsewhere, Roma continued their pursuit of Inter Milan as they cruised past Catania with a 2-0 win.
Ludovic Giuly put Roma in front only eight minutes into the game while stand-in captain Daniele De Rossi secured the win from the penalty spot in the second-half.
The win raised Roma’s point tally to 42, four adrift of Inter who take on Parma later on Sunday, and five points ahead of Juventus who played out a goalless stalemate with Sampdoria.
In other matches, Livorno edged past Empoli with a 1-0 win, Lazio held hosts Napoli to a 2-2 draw, Palermo lost at home to Siena 3-2 and Reggina beat Cagliari 2-0.