Ulster's hopes of winning the M Donnelly Inter-provincial Football title for a third successive year survived a stern examination in a well-contested semi-final at Navan's Pairc Tailteann.
Leinster led by six points early in the second half and after Conor McManus levelled matters at the end of regulation time, Luke Dempsey's charges were five to the good in the first of the two additional periods.
However, Ulster stormed back strongly for two late frees, both converted by Michael Murphy sealing what had looked an unlikely victory.
While Ulster would obviously like to complete a hat-trick of successes in the competition and high profile personalities from the province like Mickey Harte and Joe Kernan have spoken in favour of getting more public interest, the game at the Meath venue was virtually ignored by the GAA public.
There were only 279 paying spectators but the many who stayed away missed a contest brimful of end-to-end entertainment and a total of 52 scores.
Kernan, manager of the northern squad, saw his side get away to a flying start with Conor McManus running on to a delivery from Sean Leo McGoldrick and firing past Paddy O'Rourke inside a minute.
The opening score was followed by a David Givney point and Ulster went on to lead by five before Leinster got on target six times in succession to edge ahead.
Points from Michael Newman had Leinster level and then ahead but the Meath forward was unlucky to blast a penalty kick off the crossbar after 18 minutes.
Shortly after that Newman's Royals colleague, Kevin Reilly, was black-carded for a challenge on Murphy and another Leinster player, Mickey Quinn, suffered a similar censure from Leitrim referee Eamon O'Grady.
The full-forward trio of McManus, Murphy and Eugene Keating shared 1-19 of the winning total with Cavan's Keating hitting six of his seven points from open play.
Wicklow forward Leighton Glynn struck for Leinster's first goal following a Newman assist from a free after 28 minutes and the sides were level (1-11 each) at the first break.
It was Leinster's turn to make an explosive start to the second half with wing-back Paul Cribben taking a pass from Newman to fire past the advancing Niall Morgan.
Leinster tails were up after that strike and points from Philly McMahon and Newman (two frees) doubled the advantage to six.
Ulster goal attempts by Keating and Kevin McKernan were then well thwarted by O'Rourke and Bryan Menton of Leinster.
It took a McManus point to leave the board reading 1-20 to 2-17 and set the scene for an additional 20 minutes of action.
Although Keating kicked the first two points of extra-time, Leinster replied with 1-4 to lead by 3-21 to 1-22. Menton, who had replaced the black-carded Reilly, showed his versatility by fisting his side's third goal.
Leinster looked to be on the way to the title decider but a goal from Peter Harte two minutes into the final phase of the game sparked off Ulster's winning burst.
That was followed by a McManus point and the last three scores were kicked over from frees.
Darren McCurry slotted over the first of them to draw the sides level again and a brace from Murphy sealed the win.
Ulster can now look forward to meeting Connacht in the final.
Ulster: R Beggan; C McKaigue, N McGee, C Walshe; S L McGoldrick, R McCluskey, P Harte (1-1); S Cavanagh (0-1), D Givney (0-1); J Kielt (0-1, free), M Poland, M McHugh; E Keating (0-7, 1 free), M Murphy (0-8, 6 frees, 1 45), Conor McManus (1-4). Subs: K Hughes (0-1) for Givney (22), N Morgan for Beggan, M Donnelly (0-1) for Kielt (both ht), K McKernan for McGoldrick (60), D McCurry (0-1, free) for Poland (70), E Donnelly for Cavanagh (80).
Leinster: P O'Rourke; D Keogan, Kevin Reilly, P McMahon ( 0-2); M Quinn, J O'Loughlin (0-1), P Cribben (1-1); P Keenan (0-1), MD Macauley (0-1); L Glynn (1-1), C Kilkenny, G Reilly (0-2); E O'Flaherty (0-4, 1 free), E O'Gara (0-2), M Newman (0-4, 4 frees). Subs: B Menton (1-0) for K Reilly (black card 20), K McManamon (0-1) for Glynn (ht), N McNamee for G Reilly (47), K Murnaghan for Quinn black card 47), T Moolick (0-1) for Kilkenny (49), P Sharry for Newman (67), G Reilly for Moolick (74 mins), Kilkenny for McNamee (82), Glynn for O'Flaherty (90).
Referee: E O'Grady (Leitrim).