Kane Hemmings' 63rd-minute opening goal was quickly cancelled out by Cameron Salkeld but Jamie Ness grabbed the winner with 10 minutes left.
James McPake's side are now just three points behind leaders Dundee United, who are away to Inverness Caley Thistle on Saturday.