Connacht staged a brilliant revival at the Sportsground to end the Ospreys' five-game unbeaten run.
Connacht (7) 24:
Tries: McHugh, Farley, O'Sullivan.
Cons: McHugh 3.
Ospreys (18) 21:
Tries: Bater, Tandy.
Pens: Henson 3.
The Welsh led 18-7 at the interval, but tries from Andrew Farley and John O'Sullivan in the last half-hour saw Connacht complete a fine comeback.
Mark McHugh, who scored a try in the first half, converted all three of Connacht's scores and added the vital penalty kick that made the difference.
The Ospreys led at half-time through James Bater and Steve Tandy scores.
Ospreys full-back Gavin Henson opened the scoring with a 26-metre penalty, backed by a strong breeze, after two minutes.
But the home side struck for the game's first try on 14 minutes when McHugh picked up a bouncing ball on the run to round Stefan Terblanche and score.
South African Terblanche was shuffled into touch by Connacht's Matt Mostyn on 22 minutes when a quick Ospreys reply looked on, but Henson reduced the deficit
to a single point with his second penalty.
Ospreys closed out the first half in front, however, thanks to a Tandy try set up by a flat pass from his back-row colleague Bater in the 26th minute.
Henson missed the conversion to the left, as did McHugh with a 35th-minute penalty, but a long Shaun Connor pass saw Bater over with two minutes remaining
as the Ospreys took an 18-7 lead into the second half.
Henson added his third goal four minutes after the restart to put the Welsh side 14 points in front, but Connacht mustered a revival on 58 minutes with Farley barging over in the left corner.
Former Ireland A international McHugh put over a superb conversion to put Connacht within touching distance.
The home side roared to the finish thanks to a first McHugh penalty on 61 minutes, then 13 minutes from time O'Sullivan clambered over near the posts
following a back-row move.
The Ospreys at least had the consolation of a bonus point for losing by seven points or less, as they bid to stay ahead of the Cardiff Blues in the scrap for Heineken Cup qualification
Connacht: Mostyn, McPhillips, Yapp, McHugh, Munn, Elwood, Walls, McFarland, Jackman, Bracken, Swift, Farley, McCarthy, Lacey, O'Sullivan.
Replacements: Fogarty, Clarke, Browne, Neville, O'Loughlin, Moore, Robinson.
Ospreys: G Henson, S Terblanche, J Storey, D Tiueti, E Seveali'i, S Connor, A Williams, P James, B Williams (capt), A Millward, A Newman, L Tait, J Bater, S Tandy, N Bonner-Evans.
Replacements: D Jones, A Jones, A Lloyd, L Bateman, R Pugh, S Williams, A Durston.
Referee: Graeme Hannah (Scotland).