The Dons had to play most of the game with 10 men after Joe Shaughnessy was shown a straight red card in the 13th minute, while the hosts also had a goal disallowed for offside after John Sutton curled the ball into the top corner of the goal.
Motherwell continued to press throughout the game and they hit the crossbar in the final stages through Shaun Hutchinson as they searched to grab a late victory.
However, it was the 10-man visiting side who were to steal progress as Andrew Considine headed home in the 83rd minute.
Johnny Hayes then cemented their surprise victory with a left-footed shot from the left side of the box having been played in by Scott Vernon to leave the final score at 2-0.
Watch the highlights here: http://www.bbc.co.uk/sport/0/football/24766245