Tiny, annoying, flying pests might seem as old as time. Gnats are the general name for a bunch of species in the diptera suborder Nematocera, which the Smithsonian describes as “non-biting flies, no bigger than a few grains of salt, [that] are attracted to fluids secreted by your eyes.” 

While their average lifespan is only about a week long, their survival through evolutionary history stretches way further. According to new research, the insects may have been around 247 million years, older than the earliest dinosaurs

In a new study published March 10 in the journal Papers in Paleontology, geologists and biologists from Spain and England delved into a recently discovered fossil that can teach us more about the beginnings, and incredible survival abilities, of the gnat. The fossil was found in a small harbor in Estellencs, located in Spain’s Balearic Islands, known for its bluish rock layers that hide remains of plants, insects, fish, and more from the Middle Triassic. 

[Related: When insects got wings, evolution really took off.]

Mallorcan scientist Josep Juárez spotted the find—a complete larva sample that left an imprint on the sides of a split rock. Upon further examination, the well-preserved fossil was identified as part of the insect order that now claims mosquitoes, midges, flies, and of course, gnats. It may be the oldest diptera specimen discovered to date, and could be a common ancestor to the more than million species in the group today.

Gnat larva fossil in rock next to a sketch
Protoanisolarva juarezi, the gnat larva representing the oldest-known diptera, 247 million years old, found in Mallorca, Spain.CN-IGME CSIC.

“While I was inspecting it under the microscope, I put a drop of alcohol on it to increase the contrast of the structures,” says study author Enrique Peñalver, a scientist from the Spanish National Research Council at the Spanish Geological Survey, said in a press release. “I was able to witness in awe how the fossil had preserved both the external and internal structures of the head, some parts of the digestive system, and, most importantly, the external openings to its respiratory system, or spiracles.”

But beyond just revealing what a baby gnat looked like at the time, the existence of this fossil shows the insect’s remarkable ability to adapt to what Oxford University Museum of Natural History’s Ricardo Pérez-de la Fuente called a “post apocalyptic environment.” 

[Related: Eyeless army ants chomped their way through Europe millions of years ago.]

The Permian-Triassic extinction occurred around the last 15 million years of the Permian period, and is famous for the extinction of around 95 percent of marine species and 70 percent of terrestrial species in such a, evolutionarily speaking, short period of time. (Some scientists even propose that the bulk of these species disappeared over a 20,000-year span right at the end of the period.) It’s known as the most severe of any major extinction episodes in Earth’s recorded history, wiping out more than half of the taxonomic groups that roamed the land and seas. Potential causes include a change in the planet’s atmosphere that led to radiation poisoning or a change in oxygen levels.

The authors of the new study also noted how this newly discovered specimen has a similar breathing system to that in some modern insects. Perhaps it’s time to add gnats to the short list of animals that could survive an apocalypse alongside tardigrades and cockroaches.