In a Nutshell
The fossil record clearly shows a line of evolution from a dog like, land-dwelling creature called Pakicetus to transitionary animals like Ambulocetus and Rodhocetus that showed some aquatic adaptations but could still walk on land, though not efficiently, and then to fully aquatic animals like Basilosaurus and Dorudon who were completely divorced from the land. This amazing evolutionary journey shows how quickly and efficiently animals can adapt from one environment to the other due to natural selection in this case favoring the transition to a fully aquatic existence. The ancestors of whales started out in the sea as all land animals did, then emerged on land, only to return to the sea once again as exclusively marine mammals that are now even better adapted to aquatic life than fish.
The Whole Bushel
The most fascinating story of evolution is that of the modern day whale. About 53 million years ago, an ancient, furry, doglike creature with hooves called the Pakicetid walked the earth. Like all land animals, this family of mammals evolved from a common ancestor of reptiles, amphibians, and fish where it eventually over millions of years transitioned from the sea to the land. Believe it or not, this ancient mammal is a direct ancestor of the modern-day Cetaceans or whales.
The fossil record that shows the Cetacean ancestry is one of the most widely accepted and established fossil lines on record. Pakicetid was a successful land mammal because it was able to adapt, particularly when it came to its food source. When land food sources were scarce, it ventured to the edge of the sea to snatch up prey. The more daring individuals would venture further and further into the water for food, such that mutations that favored swimming and adeptness in the water were more successful than others due to natural selection and were therefore passed on to future generations. This process continued for 8 million years until the land mammal had evolved into an exclusively marine mammal that continued to evolve over another 45 million years to become modern-day whales.
Ambulocetus is considered to be the whale missing link, as it was seen as a perfect transitionary creature between land and sea mammals because it possessed traits suitable for both environments. Another whale predecessor, Maiacetus was discovered with a fetus positioned for birth head-first, indicating they likely gave birth head-first on land, unlike whales who give birth tail-first at sea. Therefore, these creatures were still transitionary between land and sea, likely returning to the land to rest, mate and give birth.
Another step in the evolutionary chain of the modern day whale was Kutchicetus, a smaller creature noted for primitive features for underwater communication that would later evolve into the echolocation systems seen in modern-day whales and dolphins. Rodhocetus, with its partially fused sacral vertebrae and large, webbed rear feet is thought to have been the first aquatic whale. Basilosaurus was the first creature to resemble modern-day toothed whales. Its vestigial hind legs were no longer able to support its weight on land, making it completely adapted to a marine environment. Several other species followed, including Dorudon, Squalodon, and Aetiocetus, which finally led to the modern Cetaceans that were exclusively suited for aquatic life and are even better adapted to sea life than fish.
Whales are the only known species whose evolution, as clearly shown in the fossil record, has its origin in the sea, where it then transitioned to a successful and well-adapted existence on the land, only to revert to an amazingly well-adapted life back in the sea.
Show me the Proof
The evolution of whales [Link]
How Did Whales Evolve? [Link]
The Origin of Whales and the Power of Independent Evidence [Link]