McDonald's goal secured a deserved win for the Dons at Pittodrie
Gary McDonald scored the winner against Inverness Caledonian Thistle that secured a top-six finish in the Scottish Premier League for Aberdeen.
The match looked to be petering out into a draw before McDonald headed home from deep inside the penalty box from a Charlie Mulgrew free-kick.
Aberdeen's Lee Miller forced a magnificent saved from Ryan Esson at full stretch in the first half.
Filipe Morais squandered the best chances for lacklustre Inverness.
The victory moves Aberdeen closer to third-placed Hearts and will have provided relief for manager Jimmy Calderwood, with a section of the Red Army having promised a protest against the current management regime after the game.
Winger Sone Aluko returned for the Dons in place of the suspended Andrew Considine, while former Aberdeen man Esson returned from suspension to take his place in goal for the visitors.
Morais, in confident mood following his brace against St Mirren last week, tested Jamie Langfield with a couple of early efforts, but the Dons goalkeeper made comfortable saves on both occasions.
Despite Caley's early dominance, it was the home side who came close to taking the lead when an accurate Derek Young cross found Miller, but the striker's header was magnificently saved by Esson.
Mulgrew, Lee Mair and Miller all went close as the Dons continued to press for an opener.
Selfish play from Morais then prevented Inverness taking the lead with five minutes to go until half-time.
The Portuguese attacker exploded past Mulgrew but opted to shoot for goal himself from a narrow angle instead of passing to one of his better-placed team-mates and Jamie Langfield made an easy save.
Inverness started the second half in a positive fashion with Morais shooting over the bar before smashing a free-kick into the wall in the opening minutes.
But everyone inside Pittodrie was at a loss to explain how Chris Maguire failed to open the scoring for the Dons when the ball fell kindly into his path after Aluko had stung the palms of Esson, but the young striker's effort came back off the crossbar.
Aberdeen were now in the ascendancy and Maguire was appealing for a penalty when he fell in the box under pressure from Lionel Djebi-Zadi but the referee waved play on.
The Dons finally took a deserved lead after 79 minutes when McDonald headed home a Mulgrew free-kick.
Their lead could have been doubled the lead three minutes later, but Esson made a fine stop from Mair's low drive and Miller could not convert the rebound.
And the Dons survived a late spell of pressure from Terry Butcher's side to earn three crucial points.
Aberdeen manager Jimmy Calderwood:
"It was a long time coming but I thought we deserved it; we were in the ascendancy most of the game.
"We had so many chances to win it I thought it was never going to come.
"Inverness are very stubborn - they're fighting for their lives.
"We couldn't get (Sone) Aluko in the game in the first half but that improved in the second. It was an important victory.
"That's us in the top six again for the sixth year on the trot and we've gained a couple of points on Hearts, so it's been a great day for us."
Inverness CT manager Terry Butcher: "When you've got certain members of the team not performing at the high levels you expect of them then we are going to struggle in the match.
"But we felt that we'd ridden a bit of an Aberdeen storm in the second half when they pegged us back.
"They hit the bar and we certainly rode our luck then.
"But to concede from a free-kick with about 12 or 13 minutes to go was disappointing considering we've got so many big men in the team and we'd been defending crosses pretty well."
Aberdeen: Langfield, Foster, Severin, Mair, Mulgrew, Jamie Smith (Duff 90), Young, McDonald, Aluko, Miller (Wright 85), Maguire (Mackie 86). Subs Not Used: Bossu, Vidal, Stewart, Paton.
Goals: McDonald 79.
Inverness CT: Esson, Tokely, Mihadjuks, Munro, Djebi-Zadi, Proctor, Kerr, Black (Duncan 65), Foran (Rooney 79), Morais (Barrowman 75), Imrie. Subs Not Used: Fraser, Hastings, Duff, Vigurs.
Ref: A Muir
BBC Sport Player Rater man of the match: Inverness's Ian Black 10.00 (on 90 minutes).
Please note that you can still give the players marks out of 10 on BBC Sport's Player Rater after the match has finished.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.