Hundreds of people had been working round-the-clock under the media glare to try to reach Julen Rosello, who plunged down a narrow shaft which is more than 100 metres (330 feet) deep on January 13 while his parents prepared lunch in Totalan, a southern town near Malaga.
"Unfortunately at 1:25 am the rescue team reached the spot where they were looking for Julen and found the lifeless body of the little one," the central government's representative in the southwestern region of Andalusia, Alfonso Rodriguez Gomez de Celis, wrote on Twitter.
A hearse arrived at the site shortly after the news broke to take his body to a funeral home.
There had been no sign of life from the boy but rescuers believed they knew where he was inside the illegal well.
Boy rescued from well dies in east China
The only evidence of the boy's presence were some strands of hair that matched his DNA and a bag of candy that he had been holding when he fell into the well.
"All of Spain feels the infinite sadness of Julen's family. We have followed closely every step to reach him," Prime Minister Pedro Sanchez wrote on Twitter.
"We will always appreciate the tireless effort of those who searched for him during all these days."
The complex search-and-rescue operation had been fraught with complications that caused delay upon delay as Julen's distraught parents and relatives stood by.
Rescuers were not able to get to Julen via the well he fell down because it was blocked by a layer of earth, sand and stones believed to have been dislodged when he tumbled into the shaft.
They decided to dig a vertical shaft parallel to the well, 60 metres deep, which was finished late on Monday.
The idea was to secure the shaft with tubes then take elite miners down in a specially made cage to start digging a horizontal tunnel to the site where they believe the child was.
But the tubes designed to secure the shaft did not fit, so they had to widen it, which delayed the operation still further.
Espresso delivery boy falls to death in Karachi elevator accident
Eventually, they succeeded and expert miners on Thursday began painstakingly digging a four-metre tunnel to join both channels and hopefully reach Julen with the help of four small, controlled explosions.
The miners worked in teams of two and were equipped with oxygen tanks.
Each small explosion took about two hours, which slowed down the rescue attempt.
Two miners had to first go down the shaft and bore a few holes. They were then followed by two specialised officers who set up the explosives.
Once they returned above ground, the explosives were detonated and then the rescue team had to wait half an hour to clear the shaft of polluted air.
Despite the passage of time, the boy's relatives held out hope that he had somehow survived the fall and would be found alive.
Jose Rosello, Julen's father, told reporters that "we have an angel that will help my son come out alive as soon as possible."
Julen's parents lost another child, Oliver, aged three, in 2017. The child had cardiac problems.
In a tweet, Spain's King Felipe VI extended his "deepest condolences to Julen's whole family".
The well was unmarked at the time of the accident and regional authorities in Andalusia said the necessary permission had not been sought before it was dug.
This race against time recalled several other high-profile cases in the 1980s.
Alfredo Rampi, an Italian boy, was found dead in a well near Rome in 1981 while Jessica McClure, an 18-month-old girl, was rescued alive from a well in Texas in October 1987 after more than two days inside.
bur-ds/mtp
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ