Williams pulled off a string of breathtaking saves to deny Brentford after the visitors had taken the lead inside 20 minutes.
Ian Henderson broke the deadlock, reacting quickest to Steven Gillespie's mishit shot to head home from 12 yards.
After that it was all Brentford as they pressed forward for an equaliser and only Williams' heroics kept his side in it. Myles Weston saw a far-post header brilliantly blocked by the keeper who then somehow tipped Karleigh Osborne's point-blank header over the bar from the ensuing corner.
Brentford eventually clawed their way back into the game after 75 minutes when Sam Saunders curled a free-kick around the wall and inside the post from the edge of the box.
Brentford could have wrapped up all three points in the dying minutes but Lewis Grabban skewed his effort wide and substitute Nathan Byrne was denied by the on-rushing Williams as injury time approached.