Miners had been drilling day and night to reach the boy, Julen, into the borehole - 100 metres (300 feet) deep and just 25 cm (10 inches) wide - which was blocked with soil.
"At 1:25 a.m. (1.25pm NZ time), the rescue teams reached the area of the well where they were looking for Julen and they found the lifeless body of the little one," said a government spokesperson in Malaga.
There had been no signs of life since the boy had fallen into the borehole as his family was walking through a private estate in Totalan in southern Spain. Rescuers found the well was blocked with soil, raising fears the well had collapsed on top the child.
(Reporting by Miguel Pereira Writing by Ingrid Melander and Joan Faus; Editing by Sandra Maler)