Queen of the South fought back to lead Falkirk at the midway stage of the Premiership play-off quarter-final.
The Bairns took a deserved lead when Blair Alston's low, driven shot whistled into the net.
Bob McHugh headed home Andy Dowie's cross to level the match after the break.
And a fine late strike by McHugh gave the Palmerston side an advantage to take into Saturday's return leg at the Falkirk Stadium.
The eventual winner will face Hamilton Academical in next week's two-legged semi-final.
Falkirk dominated the opening stages and Alston struck a fine shot past Zander Clark in the eighth minute.
Alston almost scored again when his 20-yard effort flew just past the post and team-mate David McCracken should have done better than plant a free header just before the break.
Queens knew they needed to improve in the second half and on-loan Motherwell forward McHugh got on the end of Dowie's cross to equalise.
The hosts began to take control and were rewarded for their second-half performance when McHugh fired home from Daniel Carmichael's pass in the final minute.
Queen of South: Clark, Mitchell, Durnan, Dowie, Holt, Burns, Kerr, McShane (Young 87), Russell (Kidd 90), Lyle (Carmichael 82), McHugh. Subs Not Used: Kevin Dzierzawski, Hooper, Atkinson, Higgins.
Goals: McHugh 56, 90.
Falkirk: McGovern, Vaulks, McCracken (Dick 76), Flynn, Kingsley, Alston, Millar, Sibbald, McGrandles, Beck, Shepherd (Bia Bi 83). Subs Not Used: Durojaiye, Bowman, Small, Leahy, Blair.
Goals: Alston 8.
Ref: John McKendrick