Dundee won to move off the foot of the First Division table and consign opponents Ayr United to the bottom spot.
Stephen O'Donnell crossed for Rhys Weston to head the visitors in front on 16 minutes.
Weston was then bundled over in the penalty area but Ayr keeper Kevin Cuthbert saved Matthew Lockwood's penalty by brilliantly diving to his left.
But the lead was doubled on 71 minutes when Leighton Mcintosh finished well from Nicholas Riley's pass.
Ayr's Mark Roberts converted his spot-kick after Lockwood's foul on Michael Moffat but Steven Milne restored Dundee's two-goal lead.
Ayr: Cuthbert, Tiffoney, Malone, John Robertson, Ross Robertson, Geggan, Trouten (Wardlaw 57), McKernon (Burke 81), McGowan (Connolly 57), Moffat, Roberts. Subs Not Used: McWilliams, Armstrong.
Booked: John Robertson, McKernon, Geggan.
Goals: Roberts 83 pen.
Dundee: Douglas, Irvine, Lockwood, McGregor, Weston, O'Donnell, Riley, Rae, Conroy, Milne, Mcintosh. Subs Not Used: Gibson, Chisholm, McKeown, Benedictis, McCluskey.
Goals: Weston 16, Mcintosh 71, Milne 87.
Ref: John McKendrick