Dinosaurs were the dominant vertebrate animals of terrestrial ecosystems for over 160 million years, from the late Triassic period until the end of the Cretaceous period , when most of them became extinct in the Cretaceous-Tertiary extinction event.