Raith Rovers have been left clinging to their dreams of reaching the Premiership after a brave defeat to Ross County.
Hearts-bound Yan Dhanda shot the top-flight side into the lead seven minutes after the break from the spot.
And, with 18 minutes remaining, Staggies skipper Jack Baldwin doubled their advantage with a header.
But Raith gave themselves hope for the second-leg when Sam Stanton hammered in a superb goal in the 83rd minute.
Team news
With six days to recover from their stirring semi-final triumph over Partick Thistle, boss Ian Murray clearly felt there was not much needing changed.
He plumped for just one alteration to his starting line-up, and that was enforced.
Kyle Turner spent the second half of the campaign on loan at Stark’s Park from County and so was precluded from facing his parent club.
In his place, Murray opted for striker Jack Hamilton to provide the attack with a focal point.
His selection resulted in Lewis Vaughan dropping into the number ten role and Sam Stanton moving to the left flank.
Frenetic opening
County came flying out the blocks in an attempt to stun Raith early.
They flooded forward at pace from the first whistle and the home side needed to cling on at times.
There were last-ditch tackles and a few blocks, notably by Dylan Corr from a Simon Murray shot after just three minutes.
Then, in the 13th minute, Ross Matthews got himself in the right place at the right time to deny the Staggies.
Dhanda embarked on a slaloming run that took him past Euan Murray at the edge of the box.
But, just as the opportunity to shoot appeared to present itself, he attempted a pass to Murray and Matthews cleared.
Raith settle
There was a moment when Rovers finally got their foot on the ball and played a series of passes to open up the play.
It seemed to calm the early nerves, just as County’s fast start was losing pace.
Murray did glance a header wide from a George Harmon free-kick and Dhanda whistle a shot over when he might have done better.
But Raith were more in the game and they will have hoped to have done better with a free-kick five minutes from the break.
The position appeared to favour Aidan Connolly but Lewis Vaughan, hero of the penalty-kicks success against Thistle, took it – and sent his effort straight into the wall.
The half finished with the Premiership men on top again, and Murray was brave to repel a Will Nightingale shot before Kevin Dabrowski stayed big to block a Jack Baldwin effort.
VAR intervention
Rovers came close to the breakthrough just three minutes after the restart.
A slick break was sparked by Aidan Connolly’s header before Vaughan returned the ball to him scampering down the right.
Cutting inside, the winger aimed a curling shot to the far post – and watched on as it agonisingly slipped the wrong side of the upright.
And, just a minute later, VAR intervened to hand County the advantage.
Eli King’s long-range drive was blocked by Murray and the visitors instantly surrounded referee John Beaton to call for a penalty.
The whistler was called to the monitor and, after a three-minute delay, he pointed to the spot.
Dhanda found the net on the left of the goal via the inside of the right-hand post.
Rovers pull back from the brink
The goal sent confidence coursing through County and in the 72nd minute they doubled their lead.
King’s rasping drive was tipped away for a corner by the diving Dabrowski.
And from Chanda’s flag-kick, Baldwin rose highest to nod down clinically from nine yards out.
At this point, Raith could not afford to concede a third. But they weathered the storm and instead reduced the deficit with a magnificent goal.
Shaun Byrne slid a superb ball inside the full-back for the overlapping Matthews and his cutback was lashed into the roof of the net by Stanton.
Grandstand finish
It was just what Rovers required – and they could have levelled with just a minute remaining.
Substitute Callum Smith nodded down a flick on from Murray to find the supporting Josh Mullin.
The winger took the perfect touch but pulled his shot wide from inside the box.
At the other end, Dabrowski saved low from Connor Randall to ensure Rovers travel north for Sunday’s second-leg just one goal adrift.
Star Man: Shaun Byrne
The on-loan Dundee midfielder was secure at the heart of the Raith side in the first-half and was calm in possession.
But the slide-rule pass that helped set up Stanton’s late strike was absolutely superb.
Player Ratings
Raith Rovers (4-2-31): Dabrowski 7; Matthews 7, Corr 7, Murray 7, Dick 7; S Brown 7, Byrne 8; Connolly 7 (Mullin 77 4), Vaughan 7 (Easton 77 4), Stanton 7; Hamilton 6 (Smith 68). Subs not used: McNeil, Thomson, J Brown, McGill, Rudden.
Referee: John Beaton.
Attendance: 6,216.