Aiming to put themselves back in the play-off picture, the Scarlets impressed in the first half with a Dan Newton try putting them 10-3 in front at half-time.
McFadden's early second half try got Leinster level, and Newton and McFadden swapped penalties before the Ireland international had the final say.
With the aid of a wind advantage the Scarlets were quick to settle at the RDS, and strong carries from Stephen Jones and Andy Fenby got them into the hosts' 22.
Jones kicked the opening points to punish Sean Cronin for a ruck infringement, but Leinster were back on terms within three minutes.
Fionn Carr raised the tempo with a slashing midfield run and with Kieran Murphy going off his feet at a ruck, McFadden converted the kicking opportunity.
Jones missed a long range attempt to respond before Leinster stepped it up again, turning defence into attack with Cronin securing turnover ball.
Just minutes later, the Scarlets looked vulnerable as they defended a maul but a combination of Josh Turnbull and Rhodri Jones prevented Jack McGrath from touching down.
Defences were on top until the 24th minute when the visitors struck for an well-executed first try.
Leinster were caught cold as Deacon Manu sprung clear from a midfield ruck, he passed for Johnathan Edwards and Newton was up in support to finish the move off to the right of the posts.
Jones converted for a seven-point advantage and that is how it remained for the break, with McFadden sending a difficult left-sided penalty wide of the posts.
Leinster did build for a final crescendo and Liam Williams was fortunate to avoid a punishment for a deliberate knock on as Isa Nacewa attacked out wide.
With the rain dying down for the start of the second half, Leinster seized their chance with a try after just 59 seconds.
McFadden's quick feet led to Scott Williams slipping and the Leinster centre ghosted through the gap and muscled his way over beneath the posts. He added the extras to square the sides up.
New England cap Ben Morgan was introduced for the Scarlets soon after. With Jones withdrawn, Newton stepped in at out-half and also booted an excellent penalty from distance.
Two minutes later, McFadden closed the gap again and Leinster began to press once more with ball in hand as replacements Leo Auva'a and Richardt Strauss tried to punch holes in the Scarlets defence.
The Welsh region stood up to the task and their defensive line held firm until replacement Damian Welch infringed at a ruck. McFadden, however, watched his kick at goal drift away to the right.
The game seemed destined for a stalemate when Nigel Davies' men won a relieving penalty with time almost up.
But Leinster managed to snaffle the ball back onto their side, and a final ruck offence from Scarlets replacement prop Phil John allowed McFadden complete his match-winning haul of 16 points.