Both sides threatened from the off, but the Basques enjoyed the first concrete chance of the night as Ander Iturraspe beat the offside trap on seven minutes, going on to fire low and drawing a save from Keylor Navas.
Real set about trying to force an equaliser against Bilbao but Kepa was in inspired form, repelling a multitude of efforts coming his way, with a 43rd-minute stop from a powerful Marco Asensio drive the pick of the bunch.
Jose Angel Ziganda's charges thought that they had doubled their lead on the hour when Raul Garcia clattered the crossbar after Williams missed his kick from close range and Cordoba had a shot blocked by Carvajal.
However, Real's talisman popped up once again to save his team's blushes, Ronaldo diverting Luka Modric's speculative drive into the bottom corner on 87 minutes to spare Los Blancos a sixth league loss of the season.
REAL MADRID (4-4-2): Navas; Carvajal, Varane, Ramos, Marcelo; Vazquez, Kroos, Modric, Asensio (Isco 69'); Benzema (Bale 69'), Ronaldo
ATHLETIC BILBAO (4-2-3-1): Arrizabalaga; De Marcos, Nunez, Martinez, Balenziaga; Iturraspe, San Jose; Lekue (Susaeta 79'), Garcia, Cordoba (Muniain 70'); Williams (Aduriz 85')