Playing before a capacity crowd Alloa were under pressure in the opening minutes when Aberdeen were awarded a free-kick and from 20 yards out Charlie Mulgrew's well struck free-kick was well saved by Raymond Jellema.
Alloa came back at the Dons and came close to an opener in the fifth minute when Brown Ferguson stepped up to take a free-kick and from 25 yards out had Jamie Langfield turn the ball away for a corner.
A dreadful pass from Alloa's John Grant was intercepted by Sone Aluko who ran at the home defence and passed to Chris Maguire, whose fierce shot from 18 yards out was deflected to the feet of Lee Miller, who netted from close range to give Aberdeen a deserved lead.
Aberdeen dominated the play but was stung by Alloa in the 40th minute with an equaliser from the penalty spot.
From an Alloa attack Dougie Hill netted from the home side, but the referee judged that a foul had taken place and blew for a penalty kick which was taken by Andy Scott, who calmly waited for the confusion to clear and fired home from the spot.
Aberdeen started the second half the stronger side and their dominance was rewarded in the 56th minute when Aluko netted for the visitors.
A long clearance from Langfield was knocked on by Miller and a moment of indecision by Alloa defenders Chris Townsley and Scott Buist allowed Aluko through to slot the ball past Jellema in the Alloa goal.
Alloa made two substitutions to freshen up their attack and came close on a number of occasions, but in the end Aberdeen's strength was enough to see the SPL side through to the next round.