On Tuesday evening, Rayan fell into a 32-metre (105-foot) shaft outside his home in the village of Ighran in the northern province of Chefchaouen.
Thousands of locals screamed prayers and well wishes while the rescue crews dug vertically and then horizontally, fearing a landslide.
They finally reached the youngster on Saturday night and removed his corpse before rushing him away to be treated by medics.
Officials from the government have now confirmed that the small kid was unable to be resuscitated and that he died tragically before rescuers could reach him.