Robert McHugh netted a last-gasp winner to earn Queen of the South a 2-1 victory over Falkirk at Palmerston Park in the first leg of their play-off quarter-final.
McHugh, on loan from Motherwell, fired past goalkeeper Michael McGovern after being set up by Daniel Carmichael.
McHugh had levelled for Queens 11 minutes into the second half when he nodded in an Andy Dowie cross from close range.
Visitors Falkirk, who had been on a seven-game unbeaten run, dominated the opening exchanges and it was no surprise when Blair Alston fired them ahead after eight minutes.
The midfielder struck a fine shot past Queens goalkeeper Zander Clark to grab his third goal in six games.
Alston almost made it 2-0 seven minutes later but his 20-yard effort flew just past the post while David McCracken should have doubled the Bairns' lead but planted a free header wide just before the half-hour.
The second leg takes place on Saturday, with Hamilton awaiting the winner in the play-off semi-final.