Scientists say they have solved one of the greatest riddles of paleontology: why dinosaurs went extinct 66 million years ago. A colossal stroke of bad luck — not just a giant asteroid — may have played a major role in the eradication of the creatures, according to a study published Monday in the journal Biological Reviews.

Had the asteroid that changed the atmospheric conditions on Earth slammed into the area that is now the Yucatan Peninsula in Mexico at a different time, dinosaurs might still be around, the scientists found.

Instead the asteroid hit at a time when rapid loss in biodiversity in the food chain was causing a dying off among large-bodied herbivores, the researchers found, making the dinosaurs even more susceptible to extinction when the asteroid obliterated other sources of food. A system of cascading extinctions set in motion a deadly spurt that killed off all nonavian dinosaurs, the study said.

With fewer animals left to feed carnivores, the dinosaurs’ ecosystem became even more vulnerable to shocks. The asteroid eventually wiped out about 80 percent of the earth’s species.

“It was a perfect storm of events that occurred when dinosaurs were at their most vulnerable,” Steve Brusatte, a paleontologist at Edinburgh University, told BBC News.

The researchers studied trends in atmospheric temperature, sea levels and volcanic activity that occurred around that time but concluded that the devastation wrought by the asteroid was primarily to blame for the sudden extinction of the massive species.

“The asteroid almost certainly did it, but it just so happened to hit at a bad time when dinosaur ecosystems had been weakened by a loss of diversity,” Brusatte told The Guardian. “If the asteroid had hit a few million years earlier or a few million years later, then dinosaurs probably wouldn’t have gone extinct.”

Al Jazeera