A first-half goalkeeping error by Tony O'Dowd cost Shamrock Rovers two points and third place in the table as Dundalk ended another difficult week with a spirited performance.
Rovers started well, but were rocked back on their heels after 25 minutes. O'Dowd seemed to think that a Shane Reddish free-kick from a difficult angle would go over his crossbar, but he misjudged it badly and the ball dipped in behind him and flew into the net off a post.
Rovers drew level on 33 minutes when Tommy Dunne picked out Jason Sherlock with a cross from the left and he showed good composure to control the ball and sidefoot past Williams from close range for his fifth goal of the season.
Rovers enjoyed plenty of possession in the second half but never really played with the confidence of the opening quarter. They will argue they got no favours from referee Hugh Byrne, who waved away two appeals for penalties late on.
SHAMROCK ROVERS: O'Dowd; Britton, Brazil, Whelan, Dunne; Woods, Colwell, Kenny, Tracey; Cousins, Sherlock. Subs: Markey for Woods (70 mins).
DUNDALK: Williams; Reddish, Capper, Brady, Crawley; Ward, Thew, McHulty, Harte; Campbell, Withnell. Subs: Sharkey for Harte (79 mins); Martin for Withnell (88 mins.).
Referee: H Byrne (Dublin).