Workers with mechanical diggers had laboured around the clock to save the five-year-old child trapped in a 32-metre deep well.
Workers retrieved the body of a young boy who was trapped for five days in a well in northern Morocco, a devastating end to a painstaking operation that gripped the nation.
The royal palace said in a statement carried by state media on Saturday that the boy had died before rescuers could save him.
Moroccan King Mohammed VI expressed his condolences to the boy’s parents.
"Following the tragic accident which cost the life of the child Rayan Oram, His Majesty King Mohammed VI called the parents of the boy who died after falling down the well,” the statement said.
An Associated Press reporter at the scene saw the boy wrapped in a yellow blanket after he was carried out from a tunnel dug specifically for the rescue.
His parents had been escorted to an ambulance before the body emerged. The ambulance reversed into the deep cut that rescue teams had excavated and took away the body.
The boy’s plight captured worldwide attention. Online messages of support and concern for Rayan poured in from around the world as the rescue efforts dragged on.
Footage posted on social media showed the scene after his body was recovered, with hundreds of distraught rescue workers and onlookers gathered at the site chanting and shining the flashlights of their phones into the air.
Delicate and dangerous operation
Workers with mechanical diggers worked around the clock to save the five-year-old child after he fell into a 32-metre (100-feet) deep well in the hills near Chefchaouen on Tuesday.
The well was just 45cm (18 inches) wide at the top and narrowed further to the bottom, making it impossible for rescuers to descend directly.
The effort was a delicate and dangerous operation, constantly delayed by heavy rocks and imperilled by the threat of landslides.
Across the country, Moroccans followed the saga on television in homes and cafes.
"I am so sad to learn Rayan has died. Sincere condolences to the parents,” said Abderrahim Sabihi, a resident of the capital Rabat who was following the rescue effort from a cafe.
Images on Moroccan media earlier had shown Rayan huddled at the bottom of the disused well.
Hundreds of villagers stood waiting nearby for news as the rescue operation continued on Saturday.
A male relative of the boy told Reuters TV the family first realised he was missing when they heard muffled cries and lowered a phone with its light and camera on to locate him.
"He was crying ‘lift me up’,” the relative said.
The hilly region around Chefchaouen is bitterly cold in winter. Food and water were lowered to the child, and he was also supplied with water and oxygen using a tube.
‘Avoid creating cracks’
By Saturday morning, the head of the rescue committee, Abdelhadi Temrani, said: "It is not possible to determine the child’s condition at all at this time. But we hope to God that the child is alive.”
Temrani, speaking to local television 2M, said rescuers had just two metres left to dig to reach the hole where the boy was trapped.
"The diggers encountered a hard rock on their way, and were therefore very careful to avoid any landslides or cracks,” he said.
"It took about five hours to get rid of the rock because the digging was slow and was done in a careful way to avoid creating cracks in the hole from below, which could threaten the life of the child as well as the rescue workers.”
The work had been especially challenging because of fears the soil surrounding the well could collapse on the boy.
His distraught parents were joined by hundreds of villagers and others who had gathered to watch the rescue operation.
The village of about 500 people is dotted with deep wells, many used for irrigating the cannabis crop that is the main source of income for many in the poor, remote and arid region of Morocco’s Rif Mountains. Most of the wells have protective covers.
The exact circumstances of how the boy fell in the well remain unclear.
The incident sparked an outpouring of sympathy online, with the Arabic hashtag #SaveRayan trending across North Africa.