The oldest known reefs are actually three and a half billion years old and they are composed of single-celled blue green bacteria. These creatures form layers and trap sediment and as they grow they build these big structures called stromatolites.
The stromatolites actually flourished right up until the Cambrian which is when other creatures evolved that grazed on them such as snails.
At the beginning of the Cambrian a new type of animal evolved called the archaeocyathans. These are strange cup-shaped animals that are possibly related to sponges but they managed to build quite significant reefs as well. However they died out before the Cambrian finished and left a big gap in reef forming.
Thirty million years later, in the following Ordovician period, new animals had evolved that could form reefs. These included the rugose and tabulate corals, which are distant relatives of modern corals, the stony sponges and the bryozoans.
These often built huge reefs, especially by the time the Devonian came around, to rival today’s complexity in size. However all this came crashing down in the late Ordovician extinction events which wiped out a lot of the marine fauna.
The recovery from this mass extinction was quite gradual and after reefs started forming again they involved quite different animals such as the bryozoans, new groups of animals such as the brachiopods which formed strange cup-shaped skeletons, but also in some cases the sea lilies, the crinoids, built quite large forests almost, on the sea floor as you can see here. By the end of the Permian, when the biggest mass extinction of all happened, most of these creatures were completely wiped out. And for about ten million years after the Permian extinction there is not a single reef anywhere in the world. We call this the reef gap.
Throughout the remainder of the Mesozoic era, the age of dinosaurs, reefs recovered in stops and starts but significantly we see the evolution of modern corals. But in the late Cretaceous they’re joined by a new group, the rudist bivalves, which grew in strange cup-like shapes with lids. Again at the Cretaceous–Tertiary boundary when the dinosaurs died out, most of these groups also were severely impacted and the rudists completely vanished.
After this mass extinction 65 million years ago, the modern era or the ‘Cenozoic’ begins, and after some time of recovery we see the development of the modern reefs that we’re still familiar with today.