Jack Milne's early goal edged Aberdeen into the Scottish Cup last 16 as the holders saw off Raith Rovers with a 1-0 win.
The Championship side gave a good account of themselves but couldn't find a goal after the early setback.
And Peter Leven's side made sure of their place in Sunday night's draw, which gave the Pittodrie side another home tie, this time against Premiership rivals Motherwell.
Aberdeen started brightly, despite having suffered four successive defeats, and had their reward after just nine minutes.
Debutant Lyall Cameron, pitched straight into the action after joining on loan from Rangers, swung in a corner that Dante Polvara met at the front post to flick on.
Jack Milne challenged Josh Rae and bundled the ball over the line. The video assistant referee (VAR) took a while to check for a foul on the Rovers keeper, but Aberdeen had the lead and the defender had his first senior goal.
The Championship side responded well to going behind and quickly went close to levelling when a mix-up led to Dante Polvara's backheel nearly evading Dmitar Mitov before the goalkeeper had to slap clear a looped passback.
Aberdeen showed a little more control after the restart. Interim manager Leven made changes before an hour had been played, bringing on Jesper Karlsson and Graeme Shinnie for Stuart Armstrong and Nicolas Milanovic.
The substitutions nearly paid off immediately when Shinnie picked out Karlsson in front of goal and in space. The on-loan Bologna forward took a touch but waited too long and his shot was deflected over.
Milne had a chance for his and Aberdeen's second from another Cameron corner but headed wide, and Leighton Clarkson had a shot deflected past as the hosts looked to make things more comfortable.
Raith remained stubborn opposition but couldn't find clear opportunities as the clock ticked down and Rae had to make a good save from Karlsson in injury time to keep the score at 1-0.
Aberdeen couldn't add to their lead in the final moments but the final whistle sealed a rare victory for the struggling side and ensured that the holders' cup defence continues, with a new manager expected to be in place for the next round.