Hooker Scott Otten crossed for two tries as Ospreys celebrated only their second Guinness Pro14 victory of the season as they edged out Ulster 26-24 at a rain-swept Liberty Stadium.
Ulster, who had come back from 23-10 down early in the second half, had a chance to win the match at the death, but Bill Johnson's 83rd-minute drop-goal attempt was charged down by Aled Davies.
In the end Ospreys deserved their win, which came through two Otten tries from line-out drives and one for Wales centre Owen Watkin, back after recovering fully from knee surgery to make his 50th appearance. Luke Price supplied two penalties and two conversions.
PRO 14: STANDINGS
Ulster also scored three tries through wing Robert Baloucoune, full-back Matt Faddes and Stuart McCloskey. Billy Burns and Johnson supplied nine points between them.
Although lock Adam Beard was included after being released by Wales coach Wayne Pivac, Ospreys were without international trio Alun Wyn Jones, George North and Justin Tipuric.
Ulster wing Louis Ludik returned from injury to start, while McCloskey and Burns were released from Ireland's Six Nations squad.
Ospreys had lost 15 out of 16 competitive games this season, including nine defeats in 10 Pro14 games, but they showed real spirit and tenacity in difficult windy conditions in Swansea to lead 18-10 at the interval.
The home side opened the score after five minutes with a Price penalty before Ulster hit back with wing Baloucoune going over from a burst by McCloskey, a try converted by Burns.
But for most of the rest of the half Ospreys dominated, with Watkin stretching out to put the ball on the line from short range for their opening try after 16 minutes. Price added the conversion.
Otten's first try after 25 minutes was awarded by the TMO and, although Price failed to add the extras, his penalty soon had the hosts further in front before Burns replied.
A second Otten try from a line-out drive opened up a 23-10 lead after 48 minutes before Ulster launched a concerted comeback.
The Northern Irishmen scored two tries in the space of eight minutes through Faddes, who went over on the right after Ospreys ran out of defenders, and McCloskey, who latched on to a fine David Shanahan cross kick.
Replacement outside-half Johnson converted both to put his side a point in front, but with five minutes remaining a Price penalty gave the hosts back the lead.
The drama was not over and in injury time Johnson lined up a 35-metre drop-goal attempt, only for scrum-half Davies to race up to charge it down.