Karim Benzema fired Real ahead in the 25th minute with an exquisite first-time finish from a Cristiano Ronaldo cross after Casemiro had begun the move with a clever long ball from the halfway line.
Athletic worked hard to get back into the game and, after Real keeper Keylor Navas produced a brilliant save to deny Inaki Williams, veteran striker Aritz Aduriz headed the home side level from close range in the 65th minute.
Casemiro restored Real's lead in the 68th, however, by controlling Ronaldo's flicked header from a corner and calmly taking his time to tuck the ball into the net from close range, thanks to some careless defending.
Real lead La Liga on 65 points, five clear of second-placed Barcelona, who have also played 27 games and host Valencia on Sunday.
Zinedine Zidane's side had returned to the top of the table last week after capitalising on Barcelona's shock defeat at Deportivo La Coruna with victory over Real Betis.
But the coach faced criticism for the team's leaky defence, which had shipped nine goals in the previous five league games.
They knew they would be tested by an Athletic side who had the second-best home record in the league and had not lost at home since being beaten by Barcelona in August.
The Basques made a more energetic start and nearly took the lead when Raul Garcia acrobatically volleyed at goal, catching Keylor Navas off guard although the goalkeeper reacted well to tip the shot away to safety.
Ronaldo had a frustrating day in front of goal, first having a strike ruled out for offside and then seeing a hooked effort turned away by Athletic goalkeeper Kepa Arrizabalaga, yet he played a crucial role in Real breaking the deadlock.
The Portuguese latched onto Casemiro's lofted pass and generously squared to Benzema, who added to his two goals at San Mames in last year's 2-1 win by meeting the bouncing pass first time and sending the ball into the far corner.
Read the full article on eurosport.co.uk: Real Sociedad fall 1-0 to Alaves