Williams provided a deft touch to Ibai Gomez’s cross and sent his header just beyond Marc-Andre ter Stegen after a tense and entertaining cup tie.
Barca certainly had the chances to win the match, with Lionel Messi and Antoine Griezmann in particular responsible for wasting excellent opportunities, but credit must also go to Unai Simon in the Bilbao goal.
Story of the match
Barcelona got off to a nervous start but did slowly grow into the match and had the first chance through Ansu Fati, but his shot was blocked by Unai Nunez.
Minutes later and Wiliams had the ball in the Barca net following a corner, only for him to be flagged offside as the ball took a slight flick of a Bilbao head on its way through.
Despite a few hairy moments playing from the back, the away side began to dominate the match from around the 20 minute mark and Messi had a decent effort blocked following good work from Fati around the half-hour mark.
For all Barca’s possession though, Bilbao were defending well and refused to give up on their high press which forced Ter Stegen into a couple of misplaced passes.
Just before half-time Messi earned his side a free-kick after being dragged down by Yeray on the edge of the home side’s area, but the Argentine could not beat the wall.
The match continued in a similar vein after the break, with Frenkie de Jong drawing a big penalty shout on 55 minutes, only for the young Netherlands international to be booked for diving.
In an attempt to force the issue Quique Setien brought on Griezmann for Fati and the change nearly worked, with De Jong having another penalty appeal turned down.
With 20 minutes to play, Griezmann had the best chance of the half after being found open in the Bilboa area by Sergi Roberto, but he shot straight at Simon who saved well with his feet.
Williams was still offering a threat on the break and shot dangerously on a couple of occasions, but it was Barca who missed another guilt-edged opportunity when Messi shot straight at Simon from close range with minutes remaining.
But it was Williams who sealed the match in injury time for Bilbao with a deft flicked header from an in-swinging Gomez cross.
Gomez shifted onto his left and Williams only needed the slightest of touches to send the ball past Ter Stegen and the San Mames into raptures.