MADRID — The Spanish authorities said early Saturday that they had found the body of a 2-year-old boy who fell into a well nearly two weeks ago, bringing to a tragic end a search operation that had gripped the nation.

The toddler, Julen Roselló, was said to have slipped into an abandoned, narrow borehole on Jan. 13, while his parents were preparing lunch in the countryside near the southern port city of Málaga.

His fall set off a rescue mission that was covered around the clock by Spanish news outlets. As the operation encountered engineering and geological obstacles, it grew to include about 300 people, including Spanish mining specialists and a Swedish company that provided the technology to help save 33 Chilean miners in 2010.

Officials had tried various routes to the toddler, whose body was trapped behind hardened soil and rock that blocked rescue workers and equipment. A government official, Alfonso Rodríguez Gómez de Celis, said that Julen’s body was found at 1:25 a.m. Saturday. A group of miners used a series of controlled explosions to help them excavate the last few meters of earth separating them from the child.