They surpassed the previous record of 263-5, set by Royal Challengers Bangalore in 2013
Following a scoreless 90 minutes, Elche took the lead with a free kick earned with Real down to 10 men after Marcelo was sent off for a foul on Tete Morente.
Experienced defender Gonzalo Verdu struck the free kick into the wall but his second effort deflected off Dani Ceballos and wrong-footed goalkeeper Andriy Lunin before ending up in the back of the net.
Real grabbed the equaliser when Isco deflected a Ceballos shot inside the box and substitute Eden Hazard scored the winner on a counter-attack after receiving a through ball from David Alaba, rounding the goalkeeper and finishing into an empty net.