The first fossils of a duckbilled dinosaur have been discovered in Africa, which means dinosaurs must have crossed miles of open water to get there.

Ajnabia odysseus was found in Morocco and dates to the end of the Cretaceous, 66 million years ago. Ajnabia was a member of the duckbill dinosaurs, diverse plant-eating dinosaurs that grew up to 15 meters long. But the new dinosaur was tiny compared to its kin - at just 3 meters long, it was as big as a pony.

Duckbills evolved in North America and eventually spread to South America, Asia, and Europe. Because Africa was an island continent in the Late Cretaceous, isolated by deep seaways, it seemed impossible for duckbills to get there.

The discovery of the new fossil in a mine a few hours from Casablanca was "about the last thing in the world you would expect," said Dr Nicholas Longrich, of the Milner Centre for Evolution at the University of Bath, who led the study. Dr Longrich said: "It was completely out of place, like finding a kangaroo in Scotland. Africa was completely isolated by water - so how did they get there?"

Study of Ajnabia's distinctive teeth and jawbones show it belonged to Lambeosaurinae, a subfamily of duckbills with elaborate bony head crests. Lambeosaurs evolved in North America before spreading to Asia and Europe, but have never been found in Africa before.

Reconstructing duckbill evolution, they found the lambeosaurs evolved in North America, then spread over a land bridge to Asia. From there, they colonised Europe, and finally Africa.

Because Africa was isolated by deep oceans at the time, duckbills must have crossed hundreds of kilometres of open water- rafting on debris, floating, or swimming - to colonise the continent. Duckbills were probably powerful swimmers - they had large tails and powerful legs, and are often found in river deposits and marine rocks, so they may have simply swum the distance.

"Sherlock Holmes said, once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth," said Longrich. "It was impossible to walk to Africa. These dinosaurs evolved long after continental drift split the continents, and we have no evidence of land bridges. The geology tells us Africa was isolated by oceans. If so, the only way to get there is by water."

In reference to this feat, the dinosaur is named "Ajnabia odysseus". Ajnabi being Arabic for "foreigner", and Odysseus referring to the Greek seafarer.

Ocean crossings are rare, improbable events, but have been observed in historic times. In one case, green iguanas travelled between Caribbean islands during a hurricane borne on debris. In another, a tortoise from the Seychelles floated hundreds of kilometres across the Indian Ocean to wash up in Africa.

"Over millions of years," said Longrich, "Once-in-a-century events are likely to happen many times. Ocean crossings are needed to explain how lemurs and hippos got to Madagascar, or how monkeys and rodents crossed from Africa to South America."

But the fact that duckbills and other dinosaur groups spread between continents, even with high sea levels, suggests dinosaurs travelled across oceans as well. "As far as I know, we're the first to suggest ocean crossings for dinosaurs," said Longrich.

The international team of scientists was led by the University of Bath with researchers from the University of the Basque Country UVP/EHU (Spain), George Washington University (USA) and the Natural History Museum of Sorbonne University (France) / Universite Cadi Ayyad (Morocco).

Dr Nour-Eddine Jalil, from the Natural History Museum of Sorbonne University (France) said: "The succession of improbable events (crossing an ocean by a dinosaur, fossilization of a terrestrial animal in a marine environment) highlights the rarity of our find and therefore its importance.

"Ajnabia shows us that hadrosaurs have set foot on African land, telling us that ocean barriers are not always an insurmountable obstacle."