The two rivals are set to meet in El Clasico at the Nou Camp on Sunday.
Ernesto Valverde's Bilbao side, meanwhile, stay ninth after a 10th defeat of the season, although they can consider themselves unlucky after a spirited performance.
Barca top scorer Robert Lewandowski, back in the side after recovering from injury, had an early opportunity when he broke clear on goal but his shot was smothered by the onrushing Julen Agirrezabala.
That seemed to spark Bilbao, who went close twice in quick succession when Williams' shot was saved by Ter Stegen and Raul Garcia's header from the resulting corner hit the bar.
Barca went ahead when Sergio Busquets' probing pass was collected by Raphinha in the area and the former Leeds forward fired across Agirrezabala and into the far corner for his second goal in successive games.