The Mesozoic era was the time of dinosaurs. They arose 240 MYA, during the Triassic, with considerable speciation toward the end of that period. Reptiles had diversified into numerous families and hundreds of species by the close of the Triassic. The dramatic calamity that ended the Triassic wrought changes in the mix.
Why dinosaurs survived the end-Triassic extinction event is still poorly understood, but this was their opportunity for ascent, which transpired gradually. As they evolved, dinosaurs lived alongside their reptilian cousins for millions of years.
The ascendancy of dinosaurs was as accidental and opportunistic as their demise and replacement by therian mammals at the end of the Cretaceous. ~ American paleontologist Paul Sereno