The Mesozoic Era began 245 million years ago after a mass extinction and was subdivided into the Triassic, Jurassic, and Cretaceous periods. It ended approximately 66 million years ago with another major mass extinction. During the Triassic, new types of animals emerged to fill empty ecological niches following the last extinction event, including the earliest dinosaurs. The Jurassic saw the rise of large herbivorous and carnivorous dinosaurs, as well as flying reptiles and the earliest birds and mammals. The Cretaceous period ended with a mass extinction that wiped out all non-avian dinosaurs and many other land and sea creatures.