Queen of the South boosted their promotion hopes as Dundee United missed the chance to move closer to second place in the Scottish Championship.
Joe Thomson fired Queens' opener and, after Lyndon Dykes had been fouled by Mark Durnan, Kyle Jacobs scored a penalty to double the visitors' lead.
Durnan's strike and Scott McDonald's free-kick brought United level in the second half.
But Thomson's second - a shot from long range - gave Queens victory.
Dundee United, who gave a debut to on-loan Celtic defender Anthony Ralston, remain seven points behind Livingston and 19 off leaders St Mirren, though the Tangerines have played two games fewer than the top two.
Queen of the South, who are sixth, are a point off Dunfermline Athletic and two behind Greenock Morton, who occupy the final play-off berth.