But Williams showed nerves of steel to control play from the half-back slot, keeping his side in the driving seat until he saw yellow in the dying moments.
Munster had an early opportunity to move ahead but O'Gara was wayward with a penalty after two minutes, with the ball landing several yards short of the posts.
The experienced Ireland international's radar was off and as he went on to strike the post with a second effort after the Scarlets were caught offside.
Williams was not in as generous a mood and put the home side 3-0 up after a series of attacking phases drew the penalty from Munster on 13 minutes.
And it was 6-0 when referee Dudley Phillips penalised the Irish side for going off their feet at the ruck giving Williams a shot at goal from just inside his own half.
But the 20-year-old struck it perfectly to extend the Scarlets' lead on 18 minutes.
The home side continued to pass the ball with good interplay among the backs and were dominating possession but Munster were looking powerful up front, winning two free kicks at scrum time.
With 12 minutes to the break the hard work of Munster's front five paid dividends earning a penalty that O'Gara struck between the posts.
But despite continuing to apply pressure to the home side it was the Scarlets who scored next, Williams nailing a penalty from halfway to restore his side's six-point lead at the break.
The game continued in the same vein at the start of the second half with the Scarlets on the attack, only for Williams to miss with his fourth penalty attempt of the evening.
But on 49 minutes he plundered another three pointer to increase the pressure on the visiting side.
Things might have been different had O'Gara had his shooting boots on, but on 54 minutes he struck the post with a penalty for the second time to let the Scarlets off the hook.
And Williams made him pay for the miss with his fifth successful strike of the evening to give the hosts a 12-point cushion at Parc y Scarlets.
Munster's cause wasn't helped when skipper Mike Sherry - at 24 one of the youngest men to captain the side - was given a ten-minute spell in the sin bin as the game entered the final quarter
And with 15 minutes left Williams looked to have put the game beyond last year's beaten finalists when he struck a drop goal to make the score 18-3.
With the result decided both sides rung the changes in the final minutes and on 80 minutes Williams was shown yellow as he was named man of the match, forcing the home side to play out the final seconds with 14 men.
With a man down Munster winger Denis Hurley finally broke through the Welsh defence to touch down for the first try of the game.
O'Gara made short work of the conversion as the Scarlets held on to claim an 18-10 victory and move above the Ospreys into the top four of the RaboDirect PRO12, opening up a five-point lead over Munster in sixth.
|Scarlets Score Card|
|Munster Rugby Score Card|