Wings Niyi Adeolokun and Williams exchanged memorable first-half tries with Jack Carty's penalty edging the opening period for the visitors.
Williams' second try and Rhys Patchell's snap drop-goal after the break gave the hosts a deserved win.
The tense win moved Scarlets up to eighth on the table.
Heenan's Connacht, coached by Pat Lam, went into the encounter propping up the table as Italian sides Treviso and Zebre picked up round-four points.
Scarlets had lost against Munster, Edinburgh and Ulster before facing a third Irish province in four games.
Connacht had one saving grace in their record this season, with their third-round game against lowly Italians Zebre abandoned amid a storm and with a replay to be scheduled.
The weather in west Wales began drably and deteriorated, but at no point threatened a second consecutive abandonment.
However, conditions and the tentativeness of both teams contributed to some scrappy play.
However, there were flashes of brilliance to savour.
Connacht's opening try was a beauty as the soft handling of prop Denis Buckley and former Blues player Tom McCartney gave Adeolokun just enough space to round the defence.
At the other end, Wales centre Jonathan Davies and his Great Britain Olympic Sevens silver medallist brother James combined to give Williams the chance to weave his way to the line.
Patchell converted, but Carty's penalty ensured Connacht's one-point lead at the break.
It took until the final quarter for the next score.
Williams had already been thwarted by last-ditch defence. Scarlets had also seen lock Jake Ball and replacement centre Scott Williams denied by narrow margins.
But after switching to full-back, Williams' wiry frame stretched beyond the clutches of Connacht's defence to touch down for his second try.
Patchell's opportunist drop-goal gave the hosts a decisive two-score lead in the 71st minute.