The Welsh region, buoyed by return of scrum half Mike Phillips from an ankle injury, got the result they need to move top of the Magners League - edging two points clear of former leaders Glasgow Warriors.
Dan Biggar, released for the match by the Wales squad, provided 14 points with a try and three penalties in a match-winning display.
Biggar found himself in the thick of the early action. First he missed a drop goal before being successful with a 45-metre penalty.
And then the 20-year-old fly-half was on hand to drag down Connacht hooker Sean Cronin to prevent a certain try for the visitors.
But Michael Bradley's men, who topped their Amlin Challenge Cup pool with six wins out of six, drew level on 14 minutes with a Keatley penalty.
Biggar then missed an easy penalty shot but from the restart the Ospreys scored a spectacular try. Full-back Gareth Owen ran in with real pace, going past two defenders and then rounded his opposite number, Gavin Duffy, as the home side led 8-3 after 17 minutes.
After a Connacht try was ruled out by television match official Nigel Whitehouse, despite number 8 George Naoupu believing he had grounded the ball, the lively visitors breached the Ospreys' 22 only for Owen to pull off a fine tackle on advancing scrum half Conor O'Loughlin.
Connacht's endeavours were finally rewarded with a second penalty for Keatley to reduce the Ospreys lead to 8-6, ten minutes before half-time.
Shortly afterwards, a flowing Ospreys attack ended with the award of a penalty which Biggar converted from the 22 to give his side an 11-6 interval lead.
Phillips emerged at half-time to a warm welcome from the home faithful and almost immediately the Ospreys opened up a 13-point lead with a penalty and try for Biggar within the first nine minutes of the restart.
Biggar went in at the left corner after receiving a reverse pass from the influential Owen.
But any hopes of them pushing on for the bonus point win had to be delayed after lock Ian Evans was yellow carded for a high tackle, and with the extra man Connacht grabbed a try through the Ireland-capped Cronin.
And 19-11 soon became 19-14 as Keatley converted a penalty from in front of the posts.
With four minutes to go, despite being down a man due to Gavin Duffy's sin-binning, Connacht then cut the deficit to just two points with Keatley's fourth penalty.
However, time was not on Connacht's side and their valiant comeback bid was thwarted as the Ospreys stood firm to make it six wins in-a-row at their Swansea home ground.
Speaking after the game, Ospreys director of coaching Scott Johnson said: "It was a poor performance, there's no escaping that, and I've told just them so in the dressing room.
"We aren't going to try and kid ourselves, we let ourselves down tonight. In many ways, some people just wanted to get through the game and expected to win, and once we'd got the points on the board took their foot off the pedal and were thinking of other things. That's not what we're about.
"Like I said during the week, there is much to admire about Connacht and I've been into their dressing room after the game to tell them that.
"We knew that they would come here tonight and make life difficult for us and that is exactly what they did.
"We've played them twice this season now and we've got two wins, which is what we set out to do, so you've got to be happy with that, even if the performance left a lot to be desired."
He added: "We are top of the league tonight, but that certainly wasn't a top of the league performance, and one thing is for sure, we won't stay there if we play like that again. The reality is, it's a good position to be in when we aren't playing well.
"We have to have some harsh words in training this week, I've asked the players to be honest with themselves, and with us, when they review the game, because as a coaching team, we will certainly be honest with them."
|Ospreys Score Card|
|Connacht Rugby Score Card|