Referee Leighton Hodges awarded a controversial injury-time penalty and moved the kick even closer as he punished Leinster for not retreating quickly enough.
19-point hero Dan Biggar was nerveless from the kicking tee, claiming a share of the spoils for the Ospreys at the end of a hugely entertaining early season tussle.
The Ospreys won the league title here at the RDS in May 2012, but Leinster dictated for most of the first half with Richardt Strauss and David Kearney running in tries.
Matt O'Connor's men should have been further ahead than 16-9 at the break, Biggar kicking the Welsh region in touch with three penalties.
Biggar and Jimmy Gopperth swapped kicks on the resumption before the Ospreys blasted ahead thanks to two tries in the space of three minutes from Joe Bearman and Ashley Beck.
It looked like curtains for the province when they had Sean Cronin sin-binned, but they managed to score 10 unanswered points while the hooker was off - Gopperth converting man-of-the-match Jack McGrath's try and adding another penalty for a 29-26 lead.
Yet there was yet another twist in this edge-of-the-seat contest, a last-gasp ruck offence paving the way for Biggar's equalising kick.
The Ospreys had been first off the mark in the Dublin sunshine, retaining posession well before a ruck infringement from Devin Toner allowed Biggar to open the scoring three minutes in.
Leinster cancelled that out with a fine try just two minutes later. Brendan Macken sparked the initial break on the right, with Gopperth and Darragh Fanning getting involved, and some fine continuity sucked in the visitors' defence for McGrath to send fellow front rower Strauss over unopposed in the left corner.
Gopperth's conversion attempt missed on the near side and Leinster - minus late withdrawal Luke Fitzgerald (tight groin) - had to make further alterations to their back-line as Darren Hudson hobbled off and Ian Madigan was introduced at full-back.
Kearney, who switched to the wing, profited from a clever counter attack for Leinster's second try in the 13th minute. The province swung turnover ball wide for Gopperth to dart through a gap and he fed Kearney who left the covering Richard Fussell for dead with a classy finish on the left.
Gopperth failed to add the extras, but the out-half's variation in open play was keeping the Ospreys guessing as Leinster continued to prosper with ball in hand.
Into the second quarter, great hands from Toner to Strauss unlocked the Welsh defence and possession was retained for Gopperth to turn a low pass into a neatly-taken drop goal.
Biggar cancelled those three points out with his second successful penalty, before the hosts' hard graft at ruck time - Mike McCarthy on his home debut was in the thick of it - led to a penalty reply from Gopperth.
But the Ospreys stayed within a converted score for half-time thanks to a late Biggar penalty after Jordi Murphy went off his feet at a ruck.
Adam and Duncan Jones were sent on for the second half to solidy an Ospreys scrum that had come under pressure in the opening 40 minutes, the former's introduction seeing him join fellow 2013 Lion Ian Evans on the pitch.
McCarthy was caught tackling Scott Baldwin without the ball and the resulting penalty was dispatched through the posts by Biggar for a 16-12 scoreline.
Although Gopperth was able to restore Leinster's seven-point advantage soon after, the momentum of the game quickly shifted approaching the hour mark.
The Ospreys, boosted by their strong bench, did damage through their forwards to create two quick-fire try-scoring opportunities which they took in clinical fashion.
Biggar popped a perfectly-timed pass for number 8 Bearman to dot down under pressure from two Leinster defenders. TMO Brian MacNeice confirmed the grounding and Biggar's conversion tied things up.
A brilliant burst up the left saw Evans release the equally influential Eli Walker and he managed to get his pass away for Beck to dive over in the corner. Where Gopperth failed from a similar position earlier, Biggar was bang on target as his superb conversion moved the Ospreys 26-19 clear.
The Leinster pack were just held up short as they tried to maul their way over for a try in response. They kept up the territory but Cronin's yellow card - awarded for a harsh scrum call - rocked them at a crucial stage.
Captain Shane Jennings, who assumed the hooker's role at the subsequent lineouts, helped Leinster regroup and a muscular close-in drive from prop McGrath saw him score underneath the posts. Gopperth converted to make it 26-all.
Biggar miscued a drop goal effort and young forwards Murphy and McGrath were both prominent as Leinster hunted for the winning score. It look to have arrived when Sam Lewis was caught offside and Gopperth split the posts with just four minutes left.
However, the Ospreys showed impressive resilience to batter their way downfield and deny Leinster their second win of the new league campaign.
|Leinster Rugby Score Card|
|Ospreys Score Card|