Madrid dominated the first half with Mariano and Raphael Varane heading off the bar in the space of two minutes.
Real Sociedad were much improved after the break and Portu scored an excellent header from Nacho Monreal’s cross.
Zinedine Zidane changed his front three after 61 minutes and one of the replacements – Vinicius – finished from Lucas Vazquez’s cross late on.
The draw brought to an end Madrid’s five-game winning run in all competitions and means they missed out on the chance to overtake Barcelona into second place.
Real Sociedad remain in fifth place.