Jay Emmanuel-Thomas flashed in a volley for Livingston in the 80th minute to set up a grandstand finish.
But Aberdeen hung on and closed the gap on Hibernian to just three points with two matches remaining in the campaign.
Livingston enjoyed the better of the opening exchanges and the Aberdeen defence had to look smart to cut out a Jackson Longridge centre that looked destined for the recalled Matej Poplatnik.
From the resulting corner, Niall McGinn's second delivery was met flush on the forehead of Hendry but Stryjek blocked brilliantly at his left-hand post.
Moments later, Livingston were back on the front foot and Aberdeen had stand-in goalkeeper Gary Woods to thank for keeping the scoreline blank.
Aberdeen then survived appeals for a penalty in the 20th minute as the home side continued to press for the opener.
Ferguson was robbed of possession on the edge of his own box by Scott Pittman. who fed the overlapping Nicky Devlin. However, Emmanuel-Thomas' drilled shot from the full-back's cutback was blocked by a sea of red.
Six minutes before the break, the Lions should have scored.
And just seven minutes into the second-half, Aberdeen found the breakthrough.
Livingston permitted their visitors too much space on the right and failed to stop McGinn's cross. McLennan's header was somehow deflected onto the crossbar by Stryjek but Hendry was first to the ricochet to bundle in from close range.
The Dons doubled their lead and looked to have sealed victory in the 74th minute.
Flo Kamberi raced clear on the left and his pinpoint cross was perfect for Hedges, who swept a brilliant left-foot shot into the far corner of the net to mark his return from three months out through injury.
However, Livingston threatened a comeback with a stunning counter 10 minutes from time.
Substitute Jaze Kabia angled a sensational diagonal cross into the box from the left and Emmanuel-Thomas spiralled a magnificent volley into the opposite corner of the net.
With just a minute left, Livi howled for a penalty when they claimed the ball struck the arm of Jack McKenzie in the box but referee Grant Irvine waved away the appeals.