A much-changed Hearts were briefly level through Bobby Burns, but despite Aberdeen keeper Joe Lewis struggling with a knee injury for more than half the match, the home side prevailed.
There was a dour opening quarter with both sides easing themselves into the game, which was perhaps a bit more understandable in the case of the visitors, Craig Levein having brought no fewer than six players into his starting side.
When the first chance eventually came, it fell to Stewart – so often at the heart of Aberdeen's good play. He dragged just wide from 20 yards after getting in front of Harry Cochrane on the edge of the area.
Hearts' first effort fell to Oliver Bozanic, as he hit a speculative effort from distance, but it proved an easy catch for Lewis.
Lewis would present an injury worry for the home side shortly before the break, the goalkeeper suffering an injury to his left knee in a collision with on-loan Leeds defender Conor Shaughnessy that left the Aberdeen man requiring lengthy treatment.
It seemed he would be forced off, but he soldiered on – and in injury time even managed to make a superb double-save to deny Clevid Dikamona and then Jamie Brandon from close range.
Concerns over the goalkeeper's fitness continued over the break with sub keeper Tomas Cerny warming up rigorously, and Lewis taking a fitness test, but on he continued.
The home side should have opened the scoring when Ferguson's flick set Sam Cosgrove free after 52 minutes, but his shot was straight at Doyle.
The deadlock was broken just two minutes later. James Wilson's cross from the right evaded the lunge of Jamie Brandon, and Ferguson took full advantage to fire home right-footed from eight yards.
But the lead lasted only a little over 10 minutes. A Bozanic cross was flicked on by Steven MacLean and then Ryan Edwards, before Burns popped up at the back post to bundle the ball home.
Aberdeen could have regained the lead after 74 minutes when Max Lowe's cross deflected off Shaughnessy, forcing Burns into a goal-line clearance.
But the winner came three minutes later as Wilson turned provider for a second time, this time his low ball from the right swept high into the net by Stewart.