Third Division Queen's Park stunned Scottish Premier League Dundee in the second round of the Scottish Communities League Cup.
The visitors moved ahead in the fifth minute through Steven Milne's low shot.
But Dundee's Neil McGregor was sent off for a professional foul on Jamie Longworth, who converted the resulting penalty on 24 minutes.
Longworth set up Sean Burns to fire the Spiders into the lead 14 minutes from the end and Dundee could not recover.
Barry Smith's side, who have picked up just one point from their opening four SPL matches, become the fourth top-flight side to be beaten by lower league opposition in round two, with holders Kilmarnock, Hibernian and Ross County all eliminated on Tuesday.
The Dens Park outfit, who were without the cup-tied Martin Boyle and injured duo Lewis Toshney and Mark Stewart, started strongly with John Baird having an effort blocked by James Brough.
A looping effort from Longworth drifted just wide as Queen's Park responded.
Dundee moved into the lead when Baird teed up Milne to rifle a shot past Neil Parry.
Ryan Conroy then hooked a shot just over the Queen's Park crossbar.
But the game changed when McGregor fouled Longworth in the box and referee Brian Colvin pointed to the spot before brandishing a red card at McGregor.
Longworth drove the ball past Rab Douglas to restore parity.
Queen's Park could have moved ahead with Burns' 25-yard free-kick, which was blocked by Douglas.
Dundee also threatened before the break with Parry tipping over Conroy's powerful strike.
Brough was denied by Douglas early in the second half and, at the other end, Baird's volley was off target.
Andy Robertson's shot took a massive deflection before falling narrowly past the Dundee goal.
But the Spiders did carve out a winner when Longworth's perfectly-timed pass found Burns, who dispatched a shot into the net from just inside the box.
And, despite some late pressure from Dundee, Gardner Speirs' side held on to claim a famous Hampden victory.
Queen's Park manager Gardner Speirs: "I thought we were patient and, in the main, we used the ball well, kept it well.
"The winning goal's a smashing goal. We're delighted to be in the next round of the cup.
"It's fantastic for our players. We've played teams from the First Division and now the Premier League so they deserve every credit they get."
Dundee manager Barry Smith: "I still think with 10 men we created enough chances to win the game.
"That's no disrespect to Queen's Park because they kept the ball well and they've got the result in the end.
"Obviously when you go down to 10 men it makes it harder but I still think we created chances and the decision-making could have been better."
"We just have to dust ourselves down and get on with it. We've got a big game on Sunday [against Hearts] and we must move on quickly and make sure that we're ready for Sunday's game."
Live Text Commentary
Full Time The game is over, as the referee blows his whistle.90:00 +1:30 Booking
Booking Davide Grassi booked for dissent.89:40
Corner taken by Ryan Conroy, Declan Gallagher takes a shot. Save by Neil Parry.88:03
James McAlister produces a left-footed shot from just outside the box that goes wide right of the goal.84:48
Neil Parry restarts play with the free kick.84:48 Substitution
Substitution Owen Ronald is brought on as a substitute for Sean Burns.84:48
Stephen O'Donnell gives away a free kick for an unfair challenge on Michael Keenan.83:41
Corner taken left-footed by Ryan Conroy, Giuseppe Capuano manages to make a clearance.83:15
Corner taken left-footed by Ryan Conroy, clearance by James Brough.82:57
John Baird delivers the ball, James Brough manages to make a clearance.79:41
Effort from deep inside the area by John Baird misses to the left of the target.75:40
Assist by Jamie Longworth.75:40 Goal scored
Goal! - Sean Burns - Queen's P 2 - 1 Dundee Sean Burns gets on the score sheet with a goal from the edge of the area to the bottom left corner of the goal. Queens Park 2-1 Dundee.75:17
James McAlister takes a shot. Save by Neil Parry.74:46
Outswinging corner taken from the left by-line by Sean Burns, save made by Rab Douglas.74:15
Andrew Robertson has an effort at goal from outside the box which goes wide left of the goal.73:43
Ryan Conroy concedes a free kick for a foul on Richard Little. Free kick taken by Richard Little.71:45
Iain Davidson fouled by Andrew Robertson, the ref awards a free kick. Direct free kick taken by Gary Irvine.66:55
Ryan Conroy takes the outswinging corner, Richard Little makes a clearance.65:15
Inswinging corner taken by Ryan Conroy, Richard Little makes a clearance.
A cross is delivered by Ryan Conroy, save by Neil Parry.63:58
A cross is delivered by James McAlister, Effort from deep inside the area by John Baird misses to the left of the goal.62:31
The assistant referee signals for offside against John Baird. Neil Parry takes the free kick.62:31 Substitution
Substitution (Queens Park) makes a substitution, with Lawrence Shankland coming on for Ian Watt.62:31 Substitution
Substitution Stephen O'Donnell joins the action as a substitute, replacing Steven Milne.61:32
Inswinging corner taken from the right by-line by Sean Burns, James Brough takes a shot. Save by Rab Douglas.60:47
Inswinging corner taken left-footed by Sean Burns, Michael Keenan takes a shot. Save made by Rab Douglas.52:00
Peter Bradley concedes a free kick for a foul on John Baird. James McAlister restarts play with the free kick.45:27
Centre by Sean Burns, Davide Grassi manages to make a clearance.45:01
The referee gets the second half underway.45:00 +1:49 Half time
Half Time The referee blows for half time.45:00 +1:21
Corner taken left-footed by Ryan Conroy, save by Neil Parry.45:00 +0:59
Shot by Ryan Conroy. Save by Neil Parry.44:48
The free kick is swung in left-footed by Sean Burns, Declan Gallagher makes a clearance.44:48 Booking
Booking Gary Irvine goes into the book.44:40
Unfair challenge on Sean Burns by Gary Irvine results in a free kick.43:35
The ball is crossed by Andrew Robertson, save made by Rab Douglas.39:32
Jamie Longworth is ruled offside. Free kick taken by Davide Grassi.37:54
Sean Burns crosses the ball from the free kick left-footed from right channel, save by Rab Douglas.37:54 Booking
Booking The referee shows John Baird a yellow card.37:50
Foul by John Baird on David Anderson, free kick awarded.34:37
Unfair challenge on Jamie Longworth by Declan Gallagher results in a free kick. Free kick taken by David Anderson.30:50
Effort from a long way out by Richard Little goes wide right of the goal.29:06
The ball is crossed by Richard Little, clearance by Gary Irvine.27:01
Free kick crossed left-footed by Ryan Conroy.27:01 Booking
Booking Richard Little goes into the book for unsporting behaviour.26:56
Ryan Conroy fouled by Richard Little, the ref awards a free kick.26:08
A cross is delivered by Ryan Conroy, Richard Little makes a clearance.24:52 Substitution
Substitution (Dundee) makes a substitution, with Declan Gallagher coming on for Graham Webster.23:48 Goal scored
Goal! - Jamie Longworth - Queen's P 1 - 1 Dundee Penalty taken right-footed by Jamie Longworth and scored. Queens Park 1-1 Dundee.23:06 Dismissal
Dismissal The referee red cards Neil McGregor for professional foul.22:56
Jamie Longworth fouled by Neil McGregor, the ref awards a Penalty.17:11
Free kick taken by Gary Irvine.17:11 Booking
Booking The referee shows Andrew Robertson a yellow card for dissent.16:56
Free kick awarded for an unfair challenge on Gary Irvine by Andrew Robertson.15:55
Free kick awarded for a foul by James Brough on John Baird. Free kick crossed by Matthew Lockwood, Andrew Robertson makes a clearance.11:14
Steven Milne fouled by Giuseppe Capuano, the ref awards a free kick. Davide Grassi takes the direct free kick.9:05
Close range strike by Ryan Conroy goes over the bar.7:38
Richard Little is ruled offside. Rab Douglas takes the indirect free kick.4:19
The assist for the goal came from John Baird.4:19 Goal scored
Goal! - Steven Milne - Queen's P 0 - 1 Dundee A goal is scored by Steven Milne from deep inside the penalty box to the bottom right corner of the goal. Queens Park 0-1 Dundee.3:17
The ball is delivered by Michael Keenan, Effort on goal by Jamie Longworth from 6 yards.1:21
John Baird takes a shot. Blocked by James Brough.0:00
The ref blows the whistle to begin the match.
Live data and text provided by our data suppliers