After a goalless first half of few chances, Lewis Ferguson fired the Dons in front after 54 minutes but Bobby Burns then equalised for the visitors.
Greg Stewart swept home the winner with 13 minutes left to move Derek McInnes' men three points clear of Kilmarnock, who host Hibernian on Saturday.