The Dundee defence were able to block Margiotta first shot from inside the area but the rebound favoured the striker and his second attempt beat Speroni.
Conor Sammon's 14th goal of the season gave Killie a half-time lead, the striker converting a rebound shot after Alexei Eremenko's free-kick was saved.