Fossil hunters have unearthed the remains of the first known creature to curl up in a little ball, and so pioneer one of the most successful defensive strategies of life on Earth.

No larger than a fingertip, the animal was found with tail tucked to head in a lump of rock, after it was buried by a sudden mudslide more than half a billion years ago.

The organism, one of the oldest trilobite species on record, was discovered by chance in a collection of fossils chipped from rocky outcrops in Jasper National Park in Alberta, Canada.

The finding points to a time 510m years ago when, faced with predators and environmental danger, creatures began to experiment with simple forms of defence. To curl up in a ball proved highly successful. The defence evolved numerous times in animals, including the ancestors of woodlice, armadillos, hedgehogs and pangolins.

Trilobites were a diverse group of marine invertebrates that emerged in the early Cambrian more than 520m years ago. They began life on the ocean floor, scavenging, filter feeding, and hunting for plankton. Some fossils show evidence of wounds and missing body parts from encounters with predators, such as anomalocaris, a vicious shrimp-like beast.

Javier Ortega-Hernández, a paleobiologist at Cambridge University, was going through the Canadian fossils when he noticed a tiny trilobite from a group called Olenellida. It appeared to have spines poking out of its head. But closer inspection under a microscope revealed that the spines came not from the head, but from the trilobite's tail, which was tucked under its body.

After going through published papers on the subject, Ortega-Hernández realised that his curled up creature preceded the previously known oldest case by millions of years. "Our discovery sheds light on one of the longest evolutionary arms races in the history of animals," he said.

The ancient trilobite had not perfected the art of curling into a ball. It left small spaces between the spines in the tail that left parts of the head exposed to danger. But it had rolled up as best it could, given the flexibility of its body. Ortega-Hernández later found a second trilobite in the collection that had also done its best to curl up. Details are reported in Biology Letters.

One of the questions the Cambridge team faced was whether the trilobites were curled up on purpose or simply squashed into the position when they died. "If the body was clearly broken, twisted, bent in odd ways, or otherwise deformed, we would be very suspicious," Ortega-Hernández told the Guardian. Instead, the specimens were curled up symmetrically, and all of the body segments were perfectly articulated, as seen in more recent and confirmed examples of curling up.

Trilobites went on to refine the move, called enrolling, and eventually managed what paleontologists call encapsulation, in which the underside of the head is completely covered and protected. The tactic doubtless helped trilobites survive for an extraordinary 270m years.

"Younger trilobites are found enrolled with some frequency, and part of the reason is that they developed locking devices that allowed them to maintain this position for long periods of time, and even after death," Ortega-Hernández told the Guardian.

The lack of a locking mechanism in older, more primitive trilobites might explain why none has been found curled up before: unless they are swiftly entombed in the position, they flatten out as their muscles fail them.

Trilobites had calcified exoskeletons called carapaces that protected their upper bodies, but their legs were vulnerable to predators. "If you can roll up and protect your vulnerable legs its obviously going to be an evolutionary advantage and the trilobites were the first group of animals to solve this problem," said Richard Fortey, the British paleontologist at the Natural History Museum in London. "It's pretty obvious from this paper it was a trick they learned very quickly. They were already doing it by the early Cambrian. Running away is good, but standing your ground and protecting yourself is equally good. It's been imitated in the animal kingdom many times," he said.