Even dinosaurs may have been afraid of snakes, a discovery suggests. Scientists have unearthed the almost complete fossil skeleton of a prehistoric snake that preyed on baby dinosaurs. The creature, which was three metres long, was "caught in the act" of pursuing a meal 67m years ago.

Its body was found in a dinosaur nest coiled around a hatched and crushed egg, and next to it was a 50cm fossil hatchling titanosaur – a small version of a plant-eating giant that as an adult weighed up to 100 tonnes. The remains of two other snakes were also found paired with eggs at the same site in Gujarat, western India.

The snake, named Sanajeh indicus, lacked the wide-open jaws of modern snakes such as pythons and boa constrictors and would not have been able to swallow a whole dinosaur egg. But baby dinosaurs would have been just the right size, according to researchers.

Dr Jason Head, from the University of Toronto in Canada, who led a study of the snake reported today in the online journal PLoS One, said: "Living primitive snakes are small animals whose diet is limited by their jaw size, but the evolution of a large body size in Sanajeh would have allowed it to eat a wide range of prey, including dinosaur hatchlings.

"This is the first direct evidence of feeding behaviour in a fossil primitive snake, and shows us that the ecology and early evolutionary history of snakes were much more complex than we would think just by looking at modern snakes today."

The fossils were uncovered in 1987 by dinosaur egg expert Dr Dhananjay Mohabey, of the Geological Survey of India. At first they were identified as the remains of a hatchling dinosaur. It was not until 2001 that palaeontologist Dr Jeff Wilson, from the University of Michigan, spotted the bone patterns of a snake.

"I saw the characteristic vertebrae of a snake beside the dinosaur eggshell and larger bones, and I knew it was an extraordinary specimen, even if I couldn't put the whole story together at that point," said Wilson. More experts were brought in, and years of further research and field trips followed.

The titanosaur eggs were laid in loose sand. Scientists believe the hatchling had just emerged from its egg when the snake struck, attracted by its movements. Predator and prey are believed to have been rapidly buried and preserved in sand and mud, possibly as a result of a storm.

Titanosaurs were among the last surviving members of a group of four-footed, long-necked plant eaters known as sauropods, which included the biggest land animals that ever lived. Like other dinosaurs, they are thought to have grown to a large size quickly after hatching. Until then, they would have been highly vulnerable to predators such as Sanajeh indicus.

"It would have been a smorgasbord," said Head. "Hundreds or thousands of defenceless baby sauropods could have supported an ecosystem of predators during the hatching season."

• This article was amended on 4 March 2010. It originally stated that the study of the snake was reported in the online journal PLoS ONE, but it was reported in PLoS Biology. This has been corrected.