Mark Reynolds scored the winning spot-kick for Aberdeen after Championship side Alloa took them to a League Cup penalty shoot-out.
Alloa hung on in normal time and extra-time despite the Dons domination.
Peter Pawlett had some of the hosts best chances in open play but Daryll Meggatt's header was not far away for the visitors.
Michael Doyle missed for Alloa in the shoot-out, allowing Reynolds to fire Aberdeen into the third round.
Cup success is one of manager Derek McInnes's main remits at Pittodrie and his charges cut it slightly fine here.
As you would have expected, Aberdeen took the game to their visitors and Niall McGinn's free-kick was collected fairly comfortably by Alloa goalkeeper Scott Bain.
The Dons threatened again from a corner but defender Mark Reynolds directed his header over the crossbar.
Bain's next test was to tip over a good volley from Aberdeen midfielder Pawlett.
Alloa manager Paul Hartley, a former Aberdeen player, almost watched his side take the lead against the run of play when Meggatt's header was diverted away from the top corner by the hand of goalkeeper Jamie Langfield.
Alloa defender Michael Doyle is left devastated by his penalty miss
The industrious Pawlett saw another one of his drives whistle over the bar as the Dons re-established their domination.
Alloa's Ryan McCord whipped over a free-kick for Stephen Simmons to knock just over to give the hosts an early second-half scare.
But more worrying for Derek McInnes's side were the injuries to two key players.
Firstly, Willo Flood pulled his hamstring while chasing the ball and then Jonny Hayes was stretchered off in a concerning state following a head-knock.
A fraught ending to the 90 minutes did not bring any goals.
Aberdeen looked rejuvenated in extra time and Meggatt had to be on his toes to intercept before Calvin Zola pulled the trigger.
Zola remained in the thick of the action, directing a header well-wide. Scott Vernon, too, missed when Bain let a long ball go through his hands.
So then, to penalties, and after both sides scored all five of their initial kicks, Doyle missed for Alloa and Reynolds scored to bring relief to Pittodrie.
- 01 Langfield
- 03 Robertson Booked (Vernon - 67' )
- 04 Anderson Booked
- 06 Reynolds
- 35 Murray
- 08 Flood (Low - 55' )
- 11 Hayes (Wylde - 67' )
- 16 Pawlett
- 22 Jack
- 07 Zola
- 10 McGinn
- 20 Weaver
- 02 Shaughnessy
- 17 Wylde
- 18 Low
- 09 Vernon
- 01 Bain Booked
- 02 Doyle
- 03 Meggatt
- 04 Gordon
- 05 Marr
- 06 Simmons (Young - 83' )
- 08 McCord Booked
- 10 Holmes Booked
- 11 Creaney
- 07 Cawley
- 09 Kirk (Fearns - 77' )
- 21 McDowall
- 12 Young
- 14 Tiffoney
- 15 Robertson
- 16 Fearns