As the game looked to be heading for extra-time, Williams popped up with an unstoppable strike from 20-yards to send the home support into raptures.
Kenny Jackett’s team had their chances and hit the woodwork on three occasions through Matt Doherty, Leigh Griffiths and Zeli Ismail.
Anthony Forde twice tested home keeper Barry Roche from distance but the League Two side always looked dangerous going forward.
Stewart Drummond forced Ikeme into a superb save after just 25 seconds, Andy Fleming zipped a shot inches wide and Danny Batth denied Stewart Drummond a tap in with a superb last-gasp clearance.
Williams twice tested the visiting keeper before producing the moment that mattered late on.