Real Sociedad twice came from behind to snatch a point in the final seconds but will still be left wondering how they surrendered the advantage in the Champions League race after dominating Real Madrid almost from start to finish.
Xabi Prieto's header in the third minute of stoppage time secured a point for Sociedad but it should have been three in a match that saw the home side create chance after chance, only to trail virtually throughout to a much-changed Madrid side who rarely let an opportunity pass them by.
Gonzalo Higuain pounced on a defensive mistake to put Madrid ahead five minutes in and after they withstood a barrage of Sociedad attacks, Jose Maria Callejon doubled the lead just before the hour mark.
Prieto got one back from the penalty spot before Antoine Griezmann levelled with 12 minutes left, but it seemed all that hard work was for nought when Sami Khedira restored Madrid's advantage seconds later.
Prieto bundled the ball over the line with the final touch of the match to salvage a point but it will still feel like two lost as Valencia move up to fourth place, two points clear of Sociedad, after a 1-0 win over Granada.
In a match between two sides whose coaches will be leaving at the end of the season - Jose Mourinho for Madrid and Philippe Montanier for Sociedad - the visitors, without the injured Cristiano Ronaldo, took the lead early on.
A horrible mistake from Mikel Gonzalez gifted possession to Higuain and he fired a low shot into the far corner to open the scoring.
From there on in, it was one-way traffic, but everything was going towards the Madrid goal as Sociedad created a seemingly endless array of chances and half-chances to level the match.
Imanol Agirretxe narrowly cleared the crossbar with a lob while Gonzalez fired into the side-netting from a corner. Diego Lopez then made a superb save to keep out Griezmann's header and moments later the goalkeeper tipped Agirretxe's header over.
Perhaps the best chance came three minutes before the break when Griezmann stretched to turn home a low cross but succeeded only in denying Agirretxe a tap-in. They would pay for that first-half profligacy as Madrid were much improved in the second half.
Gonzalez's desperate tackle denied Higuain a second two minutes after the restart before Kaka curled a shot narrowly wide and Inigo Martinez was dangerously close to heading in an own goal.
The second goal duly arrived in the 57th minute as Kaka's cross found Callejon, who made his first telling contribution by tucking it home.
Sociedad got a lifeline when Khedira handled and Prieto rolled home the spot-kick just after the hour-mark, and soon after they might have been level.
But Griezmann, having latched on to a defence-splitting ball, could only find the side-netting after being forced wide when rounding the goalkeeper.
Sociedad levelled in the 78th minute when Carlos Martinez whipped in a low cross and Griezmann tapped in at the far post, grateful that the lunging Agirretxe had missed it in an almost carbon-copy of their first-half mix-up.
Hope was rekindled among the home fans, but not for long as Madrid retook the lead almost immediately, Khedira lifting the ball over the goalkeeper after a neat one-two with Mesut Ozil opened up the defence.
Sociedad did not give up, and after Agirretxe missed a sitter and Griezmann's goal was ruled offside, Prieto's late header earned a point.