St Mirren paid for a slow start as Aberdeen gave away nothing at the back to hold on and book their place at Hampden in early April.
The only down side for the visitors was a hamstring injury for Scott McKenna – hours after his fellow Scotland centre-back John Souttar suffered a serious Achilles injury during Hearts' win over Rangers.
Aberdeen threatened in the opening moments when Curtis Main headed just wide from Dean Campbell's free-kick.
The visiting fans celebrated confirmation of Rangers' exit from the tournament and they were soon cheering again as their team went in front.
Matty Kennedy picked up a loose ball on the halfway line, drove forward and passed inside for Ferguson, who took a couple of strides and guided the ball through a narrow gap into the near top corner.
St Mirren could not impose themselves on the game at all in the opening half hour and their only glimpse of goal in the first half came in the final minute. Centre-back Conor McCarthy brought down Cammy MacPherson's free-kick 10 yards out but Aberdeen goalkeeper Joe Lewis got to the ball before him.
Aberdeen almost killed off the contest when Main netted with a diving header from Niall McGinn's cross but the striker was flagged offside in a very close call.
Lewis made his first save just after the hour mark when he pushed away Jamie McGrath's curling effort from long range and St Mirren, with McAllister probing for openings, were dominating possession.
Dons substitute Sam Cosgrove missed a decent chance with two minutes remaining but he soon got his goal.
McCarthy gave the ball away deep inside his own half and Sam Foley pulled Cosgrove down. The striker slotted home to continue his record of scoring a penalty in each round of the tournament.