Madigan, who replaced a groggy Brian O'Driscoll for the closing half-hour, unlocked the visitors' defence with an O'Driscoll-esque break to put Leinster in front for the first time.
Jimmy Gopperth converted and Leinster's defiant defence held the Ulstermen at bay in a frantic finish, with the 13-9 result keeping alive O'Driscoll's dreams of a fourth PRO12 title.
The comeback win ensured that the retiring O'Driscoll - a league winner in 2001, 2008 and 2013 - will have his career swansong when Leinster host Glasgow Warriors in the May 31 final.
His long-time centre partner Gordon D'Arcy ended the first half in the sin-bin, with Ulster full value for their 6-0 interval lead thanks to two Paddy Jackson penalties.
Out-of-sorts Leinster fell further behind following a third Jackson kick, but they came to the fore in the closing stages despite losing backs O'Driscoll, Fergus McFadden and Dave Kearney in an attritional derby clash.
Ulster played the better rugby for the first hour, however they did not have the points to show for it and their attempts to win silverware for retiring captain Johann Muller fell short.
Leinster have been Ulster's knockout nemeses in recent seasons, defeating their provincial rivals in league and Heineken Cup finals and now two league semi-finals (2011 and 2014).
Incredibly, it will be Leinster's fifth straight league final appearance as they bid to become the first team to successfully retain the trophy. The RDS will host the decider for the fourth time in five seasons.
Ulster were the last team to beat Leinster in league fare at the RDS in March 2013, and they made the return trip in buoyant mood after their second-string team claimed Munster's scalp last weekend.
Mark Anscombe welcomed back key men Rory Best and Ruan Pienaar into a much-changed side, the latter pulling a long-range penalty wide in the fourth minute.
As Ulster dictated early on, Pienaar put Tommy Bowe through a gap and Iain Henderson had to be hauled down five metres short before Jackson gave the visitors a deserved advantage.
Leinster got a psychological edge from a scrum penalty, but they were left to rue two crooked lineouts and a kick out on the full from their latest centurion Eoin Reddan.
The Kearney brothers combined to offer the first glimpse of Leinster's attacking class, Dave weaving his way over halfway and fellow winger McFadden added further momentum to the eye-catching counter.
Again, though, errors stopped Leinster in their tracks and a slashing midfield break from Gopperth also came to nothing as Ulster forced a turnover.
Leinster then coughed up possession for a third time in the visitors' 22, Cian Healy knocking on after a decent lineout maul.
D'Arcy saw yellow for a late tackle on his Ireland colleague Bowe six minutes before the break, allowing Ulster to dominate up to the half-time whistle.
Snappy passing released Jared Payne and Craig Gilroy to take Ulster back into the Leinster 22 and Jackson punished a Reddan offside with the last kick of the half.
The second period burst into life with strong carries from Trimble and Healy, D'Arcy's return briefly steadying the Leinster ship as the jinking Gilroy grew in influence.
There was concern for O'Driscoll who was left prone after an awkward tackle on Henderson. The record Irish caps holder received a rapturous reception as he was replaced by Madigan.
A frustrating night for Leinster's centre duo continued as D'Arcy came in from an offside position and Jackson mopped up with the three points. However, the Ulster out-half had to hobble off soon after with James McKinney - the match winner against Munster - coming on.
The complexion of the game seemed to change as man of the match Madigan broke the line and Leinster drew a 58th-minute penalty which Gopperth drove through the uprights.
Back came Ulster, McFadden having to scramble back to rescue the situation after Gopperth was charged down by Pienaar.
But Leinster's strong bench, which included the fit-again Sean O'Brien, swung the momentum back in their favour as Gopperth's second penalty made it a three-point game.
The excellent Gilroy almost put Roger Wilson over in the left corner and Pienaar was chopped down in sight of the try-line as Ulster responded in determined fashion.
The knocks kept coming as a knee injury sidelined Dave Kearney, forcing Leinster to bring reserve scrum-half Luke McGrath onto the wing.
Despite the disruption, Matt O'Connor's men managed to turn the screw as Madigan was fed to burst in between McKinney and Payne and score the only try of the night. Gopperth nailed the important conversion from the left, leaving Ulster four points adrift.
Best and company threw the kitchen sink at the home side in the dying minutes, Payne being held up just short and two lineout mauls were also thwarted as Leinster's superior defence just about won out in the end.