Hearts bounced back from the disappointment of being eliminated from the Europa Conference League to defeat RFS 2-1 at Tynecastle and secure the consolation of a third-place finish in Group A.
Both sides had been dealt a pre-match blow as their slender hopes of progressing to the knockout phase were extinguished after Fiorentina beat Istanbul Basaksehir in the other match in the section, which finished shortly before the clash in Edinburgh got under way.
But Hearts showed no sign of despondency as they raced into a two-goal lead through early strikes from Lawrence Shankland and Andy Halliday before a wonder goal from Kevin Friesenbichler brought the Latvian champions back into it.
Jambos boss Robbie Neilson made three enforced changes to the side that started Sunday’s 4-3 defeat at home to Celtic as Jorge Grant, Shankland and Halliday replaced injured duo Stephen Humphrys and Cammy Devlin and the ineligible Robert Snodgrass.
With just three minutes gone, the home side opened the scoring when Shankland slid in to poke the ball home from close range after Josh Ginnelly was released down the right by a pass from Grant and fired over an inviting low cross.
Five minutes later, an RFS corner caused panic in the Hearts box before Petr Mares volleyed the loose ball just over from 25 yards out.
But the hosts extended their lead in the 12th minute when Grant’s cutback teed up Halliday just inside the box and the midfielder’s low shot took a deflection off Vitalijs Jagodinskis and wrong-footed goalkeeper Pavels Steinbors on its way into the net.
Stephen Kingsley then had to make a vital block inside his own box to stop a shot from Friesenbichler going in after after a mistake from Orestis Kiomourtzoglou allowed RFS to mount a threatening attack.
At the other end, Kingsley saw a curling free-kick from just outside the box tipped over by Steinbors in the 31st minute.
The visitors started to grow into the game towards the end of the first half and, in the 34th minute, captain Tomas Simkovic saw a dangerous shot deflected just wide. From the resulting corner, Craig Gordon had to make an instinctive save to deny Friesenbichler.
The Latvians got themselves on the scoresheet in the 39th minute when Friesenbichler fired a stunning half volley from 25 yards out beyond the reach of Gordon.
And Friesenbichler almost pulled his side level on the hour mark with another brilliant strike from outside the box that crashed back off the underside of the bar.
Hearts – already plagued by a host of injuries to key men – suffered another blow midway through the second half when Kingsley was forced off with a hamstring problem.
They almost restored their two-goal cushion in the 72nd minute when Shankland headed Barrie McKay’s cross against the post. RFS were reduced to 10 men in stoppage time when Jagodinskis was shown a straight red card for a foul on Euan Henderson.