"Fish" is a word used to refer to any non-tetrapod vertebrate. The evolutionary history of fish began 530 million years ago, in the mid-Cambrian period. Some of the oldest known animals in the evolutionary history of fish are Pikaia gracilens, which resembles the modern-day lancelet, found in the famous Burgess shale assemblage, and Haikouichthys and Myllokunmingia from the Maotianshan shales of southern China. These simple jawless fish existed for approximately 100 million years until the first jawed fish evolved. These are also the earliest known vertebrates.
Initially, fish were minority members in an ecosystem dominated by invertebrates, especially brachiopods, sponges, and arthropods such as trilobites. It wouldn't be until the Silurian period, roughly 420 million years ago, that jawed fishes evolved and began to compete effectively with invertebrates. The earliest jawed fishes were placoderms, a family of fish with special head and thorax armor to protect them from predators. These fish are the ancestors of all modern vertebrates, including humans and all our pets and livestock.
The jawless fish were quickly outcompeted, leaving behind only a few small lineages which eventually gave rise to modern-day hagfish, lampreys, and lancelets. Sometimes these animals are not considered true fish because of their radically different physiology. There is even some disagreement as to whether lampreys are vertebrates at all, as their cartilage "skeleton" is so primitive.
The evolutionary history of fish continued with the dominance of the jawed fishes, especially placoderms, which grew as large as 6 m (20 ft) in superpredators such as Dunkelosteus telleri. Large predators like Dunkelosteus are considered the first vertebrate superpredators, and solidly established the role of vertebrates as apex predators in the world's ecosystems, a role which would continue for the rest of evolutionary history. Placoderms dominated throughout the Silurian period, for several dozen millions of years, until the Devonian, when fish began to rapidly diversify.
The Devonian was the greatest milestone period in the evolutionary history of fish, when many modern and extinct forms evolved from the placoderm seed, including sharks and rays, acanthodians ("spiny sharks," now extinct), ray-finned fishes (which dominate the seas today), and lobe-finned fishes, which eventually evolved into terrestrial vertebrates. Fishes successfully outcompeted many other marine organisms to become the dominant mobile marine animal, sharing the seas with small arthropods such as copepods and krill.
Though lobe-finned fishes and acanthodians demonstrated momentary success during the Devonian, acanthodians had pretty much died out by the end of the next period, the Carboniferous, while lobe-finned fishes became a tiny minority after giving rise to tetrapods during the same geologic period. For many years, they were thought to be represented only by the lungfish, until a coelacanth was pulled in off the coast of South Africa. The discovery of a living coelacanth was considered one of the biggest zoological finds of the 20th century.