Ronaldo, playing his 164th game in all competitions since joining Real from Inter Milan in 2002, volleyed in Zinedine Zidane's low free kick in the 26th minute at Santiago Bernabeu Stadium.
Sociedad equalized through Mark Gonzalez in the 62nd to leave Madrid 10 points adrift of Barcelona, which visits Racing Santander on Sunday,
Barcelona now needs only nine points from its remaining seven games to ensure it retains its title.
Madrid, which last won a major trophy in 2003, was replaced in second position by Valencia, which edged Celta Vigo 1-0 courtesy of Miguel Angel Angulo's goal.
Midfielder Jose Maria "Guti" Gutierrez added to Madrid's difficulties in the 86th minute by insulting the referee and receiving a red card.
"We didn't expect this game. We had been making good progress in terms of our play, discipline and attitude," Madrid coach Juan Ramon Lopez Caro was quoted as saying by news agency Efe. "The team tried hard to reach our opponent's goal and win the match but we failed."
Following discussions with Madrid president Fernando Martin after the game, Lopez Caro canceled an arrangement for the players to have two and a half days off this week. He scheduled training sessions instead, Efe reported.
In other 32nd-round games, Getafe won 2-1 at last-place Malaga, while another struggler, Cadiz, drew 1-1 with Real Betis.
FC Barcelona leads the league with 69 points, followed by Valencia and Madrid with 59. Osasuna has 55 points, four more than Sevilla and Celta.
Also on Sunday, it's: Villarreal vs. Deportivo La Coruna; Espanyol vs. Atletico Madrid; Athletic Bilbao vs. Mallorca; Alaves vs. Osasuna; and Sevilla vs. Zaragoza.
Madrid, without injured David Beckham and suspended Roberto Carlos, struggled as a lively Gonzalez fired several shots before Ronaldo scored his fourth goal in as many games.
The Brazilian limped off the field to applause in the 57th minute. In February, Ronaldo said he was considering leaving because he was tired of criticism from Madrid fans at games.
Five minutes later, Gonzalez took advantage of a mistake by goalkeeper Iker Casillas, who pushed the ball into his path.
Sociedad, which is threatened with a return to the second division after 39 years, stayed 18th with 32 points.
Valencia scored the only goal of the game at Celta's Balaidos stadium on the half hour when Angulo fired home from just outside the area after the ball was laid into his path by Mario Regueiro.
Valencia's victory boosted its chances of a second-place finish which would secure a berth in the group stages of next season's Champions League.
Getafe striker Veljko Paunovic added to Malaga's relegation worries by scoring both goals in his side's victory.
Paunovic's deflected drive opened the scoring at Malaga's La Rosaleda stadium in the 19th minute, although substitute Pablo Counago equalized early in the second half with an angled shot.
After Malaga had defender Fernando Sanz ejected for a foul in the 85th, Paunovic fired Getafe's winning goal in injury time to leave Malaga winless in 10 matches and nine points from safety.
Getafe, which has won three straight matches, rose to ninth place with 46 points. Malaga, which last played in the second division in 1999, has 23.
Cadiz took a 69th-minute lead through Lucas Lobos' penalty, with visiting Betis leveling just before the final whistle through a glancing header by Spain winger Joaquin Sanchez.
Cadiz stayed 19th in the 20-team standings with 28 points, while Betis remained 12th with 37.