Cardiff twice led as Andries Pretorius and Alex Cuthbert both grabbed tries, Harry Robinson also getting on the scoresheet, but it wasn't enough at Parc y Scarlets.
In turn nor was it enough for the Scarlets to finish in the top four as Glasgow ran out 24-3 winners against Connacht to book a RaboDirect PRO12 semi-final play-off at Leinster.
Cardiff, with nothing to play for, drew first blood as back-row Pretorius crossed and fly-half Ceri Sweeney slotted the conversion to make it 7-0 after just three minutes.
Rhys Priestland registered the Scarlets' first points with a penalty moments later before Cardiff had a breakaway try from wing Robinson ruled out for a knock on.
And as it was the Scarlets grabbed their first try of the game in similar fashion - scrum-half Davies quickly picking up from a ruck and storming more than half the field to score.
Priestland converted as the hosts led 10-7 going in the break only to see Cardiff start the second half as they did the first with a try from wing Cuthbert.
He completed a sweeping move involving scrum-half Lloyd Williams, Casey Laulala, Chris Czekaj and Dan Parks, on as a replacement for Sweeney, but failed to convert.
No sooner had Cardiff taken the lead than were Scarlets back in front as Josh Turnbull forced a turnover and passed one-handed to Kieran Murphy with Davies eventually going over.
He held off a tackle from Dafydd Hewitt, recovering after going down, to score with Priestland making it three from three on the night with the conversion.
Yet the visitors responded immediately with 52 minutes on the clock with Robinson completing a well-worked move after the Blues themselves had fumbled from the restart.
With the teams level at 17-17 each, the scoring died down until the 64th minute when Parks, playing his last game for the Blues, slotted a penalty from a similar area to his missed conversion.
However wing Williams hit back for the Scarlets as the last ten minutes beckoned, bundling his way over after smart play from replacement Jon Edwards and Turnbull.
Priestland missed the conversion to keep the contest on a knife edge at 22-20 but a penalty try with five minutes left, this time added to by the Wales international, settled matters.
|Scarlets Score Card|
|Cardiff Blues Score Card|