Lionel Messi, meanwhile, finished Barcelona's 1-0 win at Villarreal with a right leg injury after he set up substitute Sandro Ramirez to score on his debut.
Messi assisted on the 82nd-minute winner and played the full match, but his club said after the game he had injured a right leg muscle and would undergo tests on Monday.
Madrid looked set to romp at Anoeta Stadium after dominating the first half hour with goals by Sergio Ramos and Gareth Bale.
But David Zurutuza scored twice on either side of goals by Inigo Martinez and Carlos Vela as the hosts roared back to leave Madrid's players with blushes to match their bright pink kits.
''We were horrible,'' said Madrid goalkeeper Iker Casillas.
Elsewhere, Isaac Cuenca converted a penalty in stoppage time to salvage Deportivo La Coruna a 2-2 draw against Rayo Vallecano, while David Lomban also scored in added time to secure Elche a 1-1 draw with Granada.
On Thursday, Sociedad was beaten 3-0 at Russian side Krasnodar, eliminating it from the Europa League playoffs and sparking speculation that coach Jagoba Arrasate's job was in danger.
''We began with many doubts after our elimination the other day, but we turned it around with a lot of courage and attitude,'' said Xabi Prieto, who flicked on a corner kick for Martinez's goal and crossed for Zurutuza to score what proved to be the winner.
Now Carlo Ancelotti will have to answer why his squad with stars like Bale, Karim Benzema and James Rodriguez failed to compete for the final hour. Madrid, which had already lost the Spanish Super Cup to Atletico Madrid, slipped three points behind Barcelona.
''I don't like this defeat at all because I think sometimes you can play poorly but when you are winning 2-0 you have to show more character to finish off the game and that is my responsibility,'' said Ancelotti. ''Something has to change and it will change.''
With Ronaldo out to nurse his nagging leg injuries, Ramos and Bale took over the scoring duties.
Ramos headed in Toni Kroos' corner kick in the fifth minute before Bale doubled the lead six minutes later with an audacious dribble to put the ball between the legs of Gorka Elustondo before scoring.
Martinez swung the tide when he slipped behind Ramos to score in the 35th. Zurutuza equalized in the 41st when he thumped in Alberto de la Bella's cross.
Casillas grazed Imanol Agirretxe's header wide in the 48th but could do nothing to stop Zurutuza's second goal in the 65th before Vela added another in the 75th.
Earlier, Messi was as incisive as in Barcelona's home opener last week when he scored two times in a win. But at El Madrigal Stadium he was twice denied by the goalframe when goalie Sergio Asenjo blocked his free kick off the post in the 28th and his shot stuck the upright in the 76th.
Neymar came on as a second-half substitute for his first competitive game since fracturing a vertebra at the World Cup, having missed last weekend's league opener with a left ankle sprain. The striker misfired twice before starting the move that led to Barcelona's goal by passing to Messi in the area.
Hemmed in by Asenjo and a defender on the right side, Messi squeezed a low pass under Asenjo for the streaking Ramirez to tap home.
New coach Luis Enrique saw another successful debut by a player from Barcelona's ''B-Team,'' which he coached from 2008-2011. Last week it was 18-year-old Munir El Haddadi who scored to round off Barcelona's 3-0 win over Elche. This time it was the 19-year-old Ramirez, who had a perfect debut after substituting Pedro Rodriguez in the 69th.
''(Luis Enrique) looks to the youth team and we try to make the most of it,'' Ramirez said.
Villarreal had its chances to go ahead after hitting the goalframe on two occasions. Barcelona defender Jeremy Mathieu almost scored an own goal in the 51st before Tomas Pina's long strike rattled the bar in the 72nd.