Maguire grabbed a dramatic late winner for the Dons
Chris Maguire salvaged Aberdeen's top six hopes with a dramatic injury-time winner against 10-man Inverness.
Sone Aluko's low shot put Dons ahead on seven minutes before Dave Bus' headed own-goal made the scores level.
Russell Duncan's 25-yarder put the home side in front on 40 minutes, but Barry Nicholson's header made it even again. Duncan then saw red for two bookings.
Lee Miller's header put Dons ahead again and Roy McBain drilled a leveller before Maguire's bundled winner.
Inverness had registered the first effort on target when Don Cowie's snap shot from the edge of the penalty area drew a smart save from Derek Soutar, but it was Aberdeen who took the lead in the seventh minute.
The architect of the goal was Miller, who spun away from Duncan in the middle of the pitch before lofting a pass out to Aluko.
The on-loan Birmingham player then embarked on a menacing run, cutting inside from the left wing before placing a low shot past Michael Fraser in the home goal.
Aberdeen looked to build on their advantage with Ricky Foster and Miller flashing ambitious shots off target.
But Inverness scored an equaliser against the run of play when Duncan's long free-kick was carelessly headed into his own net by Bus.
Craig Brewster's men forged ahead five minutes before the break when Cowie laid the ball off to Duncan 25 yards from goal and his left-foot shot flew into the net for his third goal of season. He was carelessly booked for over-celebrating.
Aberdeen restored parity on the stroke of half-time. Nicholson stole in behind Phil McGuire to head home Foster's cross.
However, the drama was not over, for scorer Duncan was issued with a second yellow card by referee Dougie McDonald.
The midfielder had kicked the ball away in frustration just after McDonald had blown his whistle to signal for half-time and that appeared to be the misdemeanour which was punished.
It took the Dons only eight minutes of the second period to make their man advantage count as Miller headed home Nicholson's inswinging corner.
But Inverness weren't giving up and remarkably made the scoreline 3-3 on 57 minutes when McBain drilled home Cowie's cross with his left foot.
Aberdeen's top six dream looked to be over as 90 minutes arrived, but up popped Chris Maguire four minutes into stoppage time to bundle home and set up a decider against Falkirk in the final game before the split.
Referee McDonald summoned Grant Munro to his room after the full-time whistle to show the Inverness defender a red card for dissent and complete a miserable afternoon for his team.
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.