The behaviour of an ancient horseshoe crab in its final moments before death has been captured in the fossil record.

A 9.7m-long trackway was created around 150 million years ago when a horseshoe crab fell into a lagoon.

The find is of interest because the fossil of the animal itself is present at the end of the trackway, where the animal died.

The research appears in the journal Ichnos.

Working out who made a trackway is normally like detective work. In this case, the suspect has been caught in the act Dr Nic Minter, University of Saskatchewan

The fossil trackway of the animal's last moments - known as a mortichnia, or death march - was discovered in the lithographic limestone of Bavaria in Germany in 2002, where spectacular fossils of the famous feathered dinosaur Archaeopteryx have also been found.

Since then, the fossil trackway had remained an exhibit in the Wyoming Dinosaur Center in the US until Dean Lomax of the Doncaster Museum and Art Gallery and Christopher Racay began working on a project to describe it

"It's not particularly rare to find these horseshoe crabs at the end of short traces, but nothing quite as substantially large and scientifically important as this," he said.

The fossil records an entire walk, and the researchers believe that the abrupt beginning of the trace can be explained by the animal being "flung" into the lagoon during a storm, although they cannot be certain of this interpretation.

However, the quality of preservation allowed the researchers to reconstruct very small details of the animal's end minutes.

Image caption Gone but not forgotten - the creature and its "death march" are exquisitely preserved

"The lagoon that the animal found itself in was anoxic, so at the bottom of these lagoons there was no oxygen and nothing was living," Mr Lomax told the BBC.

"This horseshoe crab [Mesolimulus walchi] found itself on the lagoon floor and we can tell by looking at the trace that the animal righted itself, managed to get on to its feet and began to walk," he explained.

However, the anoxic conditions of the lagoon floor quickly proved fatal to the arthropod and it soon began to struggle.

"We started to study the specimen closer and saw that the walking patterns and the animal's behaviour started to change. The leg impressions became deeper and more erratic, the telson (the long spiny tail) started being lifted up and down, up and down, showing that the animal was really being affected by the conditions," he said.

"To find a trackway and its track-maker preserved together in the fossil record is extremely rare. Working out who made a trackway is normally like detective work. In this case, the suspect has been caught in the act," Dr Nic Minter, currently of the University of Saskatchewan, Canada, who was not involved in the study, told BBC News.

"Discoveries such as this provide unique insights into the behaviour of extinct species - in this example during the last throes of its life and the environmental conditions that led to its demise," he said.