Leinster's 20-match unbeaten run was ended as the Ospreys took a deserved win in the Pro12 clash at the RDS as Brian O'Driscoll returned to action.
The home side led 19-6 early in the second half but George Stowers' try gave the Ospreys hope before the Welsh club produced a big finish.
Richard Hibbard's 77th-minute try cut Leinster's lead to a point before Dan Biggar kicked a superb conversion.
Ian Madigan's try had helped Leinster lead 16-6 at half-time.
O'Driscoll was having his first outing since the Rugby World Cup while captain Leo Cullen also returned from Achilles surgery to partner debutant All Blacks World Cup winner Brad Thorn in Leinster's second row
The Ospreys had Wales' Grand Slam winners Alun Wyn Jones, Ryan Jones and Justin Tipuric in their starting line-up, but fell behind to a second minute penalty from Fergus McFadden.
However, Andrew Bishop's counter-attack led to an Ospreys penalty in the Leinster 22 which the impeccable Biggar landed.
Without getting through the gears, Leinster forced two more penalties which McFadden landed to give the home side a 9-3 lead by the 26th minute.
The Ospreys' prospects were being undermined by a series of midfield handling errors and they looked in big trouble in the 33rd minute when Madigan scored Leinster's try.
Richardt Strauss' line-out from just outside the 22 flew beyond his jumpers but Madigan picked up the loose ball and charged past Hanno Dirksen to score.
McFadden's conversion extended Leinster's lead to 16-3 although Biggar replied with an Ospreys penalty before the break.
Another McFadden penalty left Leinster 13 ahead again just after the break but a superb Richard Fussell run set up a simple penalty for Biggar on 50 minutes.
The Ospreys were well and truly back in the contest a minute later as a Dirksen break and fast hands from Ashley Beck set up a tremendous try for Samoan star Stowers.
Biggar's extras cut the deficit to only three and the Ospreys then crucially repelled some Leinster pressure at the other end as Heinke van der Merwe was held up twice over the line by brave defending.
After O'Driscoll and Thorn had departed just before the hour, the Ospreys suffered a setback when Wales flanker Justin Tipuric was harshly sin-binned for what referee Peter Fitzgibbon deemed a dangerous spear-like tackle on Kevin McLaughlin.
However, McFadden missed the resultant penalty and with the Leinster scrum under massive pressure after losing tighthead prop Nathan White and his replacement Jamie Hagan to injury, the Ospreys sensed their chance.
The late pressure yielded Hibbard's 77th-minute try after the use of the television match official and man of the match Biggar held his nerve to slot the difficult conversion from the touchline, with the aid of an upright.
Leinster: Isa Nacewa; David Kearney, Brian O'Driscoll, Fergus McFadden, Luke Fitzgerald; Ian Madigan, Isaac Boss; Heinke van der Merwe, Richardt Strauss, Nathan White; Leo Cullen (capt), Brad Thorn; Rhys Ruddock, Dominic Ryan, Leo Auva'a
Replacements: Fionn Carr for Kearney 68, Eoin O'Malley for O'Driscoll 58, Sean Cronin for Strauss 59, Jamie Hagan for White 30, Damian Browne for Thorn 55, Kevin McLaughlin for Auva'a 55, Jack McGrath for Hagan 59.
Not Used: Cooney.
Ospreys: Richard Fussell; Hanno Dirksen, Andrew Bishop, Ashley Beck, Eli Walker; Dan Biggar, Kahn Fotuali'i; Paul James, Richard Hibbard, Aaron Jarvis, Ryan Jones, Alun Wyn Jones (capt), Tom Smith, George Stowers, Justin Tipuric.
Replacements: Adam Jones for Jarvis 58, Ian Evans for R Jones 72, James King for Stowers 59.
Not Used: Scott Baldwin, Ryan Bevington, Rhys Webb, Matthew Morgan, Tom Isaacs.
Referee: Peter Fitzgibbon (Ireland)
Assistant Referees: Simon McDowell, Olly Hodges
Citing Commissioner: Murray White
TMO: Alan Rogan