First Division strugglers Queen of the South emerged from Pittodrie with a Scottish Cup fifth round replay as Aberdeen came back from a goal behind.

The Dons had the upper hand in the match, especially in the second half, yet found themselves trailing when Queens' Scott McLaughlin stroked home.

Rory McArdle smashed a header off the bar before Scott Vernon prodded the equaliser from Kari Arnason's throw-in.

Mitch Megginson blazed over the bar in the final minute as Queens held on.

Media playback is not supported on this device

Interview - Queen of the South manager Gus MacPherson

Aberdeen gave an early, and false, indication of their attacking intent after only two minutes.

Fraser Fyvie, who has told the club he will not be renewing his contract when it expires at the end of December, took an inswinging corner and, when the ball fell to Rory Fallon inside the six-yard box, the striker fired wide of the target.

And there was a different sort of attack, with intent questionable, when Arnason challenged Queen of the South's Stephen McKenna with his foot at head height. Referee Steven McLean booked the Icelander.

On 19 minutes, Ryan Jack skipped away from the Queens defence down the right wing and sent in an inviting ball for Fallon, whose volley flew six feet wide of Lee Robinson's left-hand post.

Josh Magennis got the Dons' one and only first half shot on goal when he pinged one in from 20 yards that Robinson saved comfortably.

The only moment for the travelling fans to get excited about was when a cross from the right was tipped away by Jason Brown but only as far as Sam Parkin who was a fraction away from connecting at the back post.

Media playback is not supported on this device

Interview - Aberdeen manager Craig Brown

The match, unlike the foul weather, improved after the break.

Queens tore the Aberdeen defence to shreds in the 54th minute, with Parkin laying the ball on for McLaughlin left of centre in the box and he coolly stroked it into the net.

Memories of cup defeats, including one at the hands of Queen of the South in 2008, must have been flashing through the minds of Dons fans as they watched their team try to recover the situation against the First Division strugglers.

McArdle smacked the crossbar with a powerful header as the Dons pinned they visitors back and soon they were level.

A long Arnason throw-in from the right gave the Queens defence plenty of time to consider how they might deal with it - but that they failed to do so and Vernon was first to react in the melee, prodding home from close range.

There were more than 20 minutes to be played at that point and Aberdeen showed the greater desire and fitness. In Jack they had a player who got forward down the right at every opportunity, though his crosses tended to fall too close to Robinson.

Megginson, on as a last-minute substitute for Jack, blew the chance to negate the trip to Palmerston for the replay when he side-footed the ball over the Queen of the South bar with seconds remaining.