Derek Lyle finished neatly after a Stephen Dobbie through ball but Thomas Mikkelsen rounded goalkeeper Lee Robinson to level for United.
Dobbie finished off a counter attack for Queens' second but Mikkelsen again equalised, converting a rebound after a Robinson save.
But strikes by Lyndon Dykes and Dale Hilson gave the hosts victory.
With Falkirk beating Raith Rovers, the Bairns move above Greenock Morton into second. United trail Falkirk by four points and are two off Morton, while Hibernian have a nine-point lead at the top.
Challenge Cup winners United host Falkirk next Saturday.
Queens move to within eight points of Dundee United but face a tall order to prevent Ray McKinnon's side claiming at least the final play-off place.
The sides finishing third and fourth will play off at the quarter-final stage with the winner going on to meet the league's runners-up. The semi-final winner will meet the team who are second bottom in the top flight in the Premiership play-off final.
Match ends, Queen of the South 4, Dundee United 2.
Second Half ends, Queen of the South 4, Dundee United 2.
Hand ball by Mark Durnan (Dundee United).
Corner,  Dundee United. Conceded by Jordan Marshall.
Goal!  Queen of the South 4, Dundee United 2. Dale Hilson (Queen of the South) right footed shot from very close range to the bottom left corner. Assisted by Lyndon Dykes.
Goal!  Queen of the South 3, Dundee United 2. Lyndon Dykes (Queen of the South) right footed shot from the right side of the box to the bottom right corner. Assisted by Connor Murray.
Substitution, Dundee United. Alex Nicholls replaces Thomas Mikkelsen.
Foul by Chris Higgins (Queen of the South).
Thomas Mikkelsen (Dundee United) wins a free kick on the left wing.
Kyle Jacobs (Queen of the South) wins a free kick in the defensive half.
Foul by Simon Murray (Dundee United).
Substitution, Queen of the South. Dale Hilson replaces Dom Thomas.
Substitution, Dundee United. Luis Maria Zwick replaces Cammy Bell because of an injury.
Corner,  Queen of the South. Conceded by Stewart Murdoch.
Corner,  Queen of the South. Conceded by Blair Spittal.
Corner,  Queen of the South. Conceded by Willo Flood.
Substitution, Queen of the South. Connor Murray replaces Daniel Carmichael.
Joseph Thomson (Queen of the South) wins a free kick in the defensive half.
Foul by Paul Dixon (Dundee United).
Substitution, Dundee United. Blair Spittal replaces Alistair Coote.
Attempt saved. Stephen Dobbie (Queen of the South) right footed shot from a difficult angle on the left is saved in the bottom right corner.
John Rankin (Queen of the South) wins a free kick in the attacking half.
Foul by Charlie Telfer (Dundee United).
Attempt missed. Simon Murray (Dundee United) right footed shot from outside the box is high and wide to the right.
Dom Thomas (Queen of the South) wins a free kick in the defensive half.
Foul by Paul Dixon (Dundee United).
Foul by John Rankin (Queen of the South).
Tony Andreu (Dundee United) wins a free kick in the defensive half.
Goal!  Queen of the South 2, Dundee United 2. Thomas Mikkelsen (Dundee United) left footed shot from the centre of the box to the centre of the goal.
Attempt saved. Paul Dixon (Dundee United) left footed shot from outside the box is saved in the centre of the goal.
Attempt missed. Stephen Dobbie (Queen of the South) left footed shot from outside the box is just a bit too high.
John Rankin (Queen of the South) wins a free kick in the attacking half.
Foul by Charlie Telfer (Dundee United).
Substitution, Queen of the South. Lyndon Dykes replaces Derek Lyle because of an injury.
Second Half begins Queen of the South 2, Dundee United 1.
First Half ends, Queen of the South 2, Dundee United 1.
Willo Flood (Dundee United) is shown the yellow card.
Goal!  Queen of the South 2, Dundee United 1. Stephen Dobbie (Queen of the South) left footed shot from the centre of the box to the bottom right corner. Assisted by Dom Thomas.
Foul by Chris Higgins (Queen of the South).
Simon Murray (Dundee United) wins a free kick on the right wing.
Queen of the South scored two late goals to beat Dundee United, who lost ground on Falkirk in the Championship.