On what proved to be a night of high drama in Glasgow's South Side it was Ryan McGuffie who scored the decisive spot kick to take his side through after 120 minutes of football had produced a 2-2 draw.
The Light Blues went behind after 48 minutes when Nicky Clark’s header beat Neil Alexander.
And after Barrie McKay had equalised on 53 minutes the Light Blues suffered another blow when substitute Kevin Kyle, who had replaced Francisco Sandaza, was sent off for elbowing a Queens player when challenging for a throw in.
But despite being a man down Lee McCulloch won a penalty with 20 minutes remaining and the skipper slotted his spot kick low beyond former Gers keeper Lee Robinson.
With time running out and Willie Gibson also seeing red in the 90th minute the game looked over but the Doonhamers’ in-form striker Gavin Reilly levelled the score at 2-2 with the last kick of the ball and this dramatic clash went into extra-time and then penalties.
McCulloch stepped up first and smashed in his second spot kick of the night before Queens sub Derek Lyle whacked his side's first effort off the cross bar.
Robinson then saved from Shiels before Nicky Clark sent Alexander the wrong way to make it 1-1.
Kal Naismith then scored with an excellent penalty before Derek Young rifled the ball down the middle to make it 2-2.
Next up was Ian Black and he also found the net as did Queens number 9 Reilly.
Argyriou then hit the post and it was McGuffie that fired the ball into the net to take the visitors through.
It was a dramatic end to a night which ended in disappointment for the Ibrox faithful and few could argue that Queens deserved their victory.
The first 45 minutes of the game were, in truth, disappointing and neither side could break the deadlock albeit Gers could have taken an early lead.
Queens left back Kevin Holt was short with a back pass to Robinson and McKay’s first time effort from a tight angle was easily gathered by the visiting keeper.
Allan Johnston’s men then showed the fighting spirit which has taken them to the top of the Second Division and on a couple of occasions they tested Alexander.
On 15 minutes Daniel Carmichael’s dangerous cross from the right wing was headed out of the 18 yard box straight to Chis Mitchell and his volley from 25 yards was tipped over the bar.
Just five minutes later and Carmichael cut inside from the right and his long range effort again had to be palmed over by Alexander who was sporting purple top, shorts and socks.
This was just about as good as it got in the opening period with both teams lacking creativity and urgency.
This all changed in the second half and it was the visitors that took a shock lead just three minutes after the restart.
Gibson did well on the left to get beyond Argyriou and his excellent cross was met by Clark who powered an accurate header beyond Alexander.
The packed away end went wild and just three minutes later Clark, the son of Queens assistant boss and former Ger Sandy, latched on to a long ball and his near post shot produced another great save from the Rangers keeper.
On 53 minutes a deflected effort from McCulloch skimmed the side netting and Rangers levelled after Sandaza had been replaced by Kyle.
Ian Black took the corner and when Derek Young sclaffed his clearance it fell to McKay who bundled the ball over Robinson and into the net from six yards.
With Kyle on the Light Blues suddenly had a player capable of causing mayhem with his power and height.
But just when Rangers were getting the upper hand the substitute received a second yellow card for a second elbow challenge.
The big striker looked baffled by the decision made by ref Stevie O’Reilly as did his manager Ally McCoist who was in deep discussion with the fourth official as the player walked up the tunnel.
Rangers, however, were then gifted the chance to take the lead on 70 minutes when Macleod fed a clever pass into the Queens 18 yard box and McCulloch was brought down by a clumsy challenge from centre half Chris Higgins.
The skipper quickly grabbed the ball and his low strike sent Robinson the wrong way from the spot.
With Kal Naismith and Sebastien Faure now on a place in the next round looked guaranteed, especially when Queens winger Gibson received a red card for a second bookable offense with 90 minutes on the clock.
But with many of the 20,932 fans preparing to leave the ground or already travelling home the visitors pushed forward in injury time and, remarkably, got their reward in the very last seconds when Reilly toe poked the ball home.
In the first half of extra time Kal Naismith had a glancing header cleared off the line and Shiels hit the side netting with a shot after Robinson had parried a Wallace drive from 15 yards.
With both teams tiring the second period failed to produce any clear cut chances until the last minute when sub Daniel Orsi missed a snip with Alexander making a crucial save.
That took the game penalty kicks and it was Queens that held their nerves to book their place in the next round.