More than 570 million years ago, Precambrian sand and mud deposits blanketed the land that would become western Montana, before the supercontinent of Pangaea broke up into Europe, Africa, and the Americas. Traces of blue-green algae are the only fossils found in Precambrian-era rocks, which can still be seen in western and central Montana, where later movements forced them to the surface. Glacier National Park  is almost entirely Precambrian in origin.
Toward the end of the Mesozoic era, tectonic plates were scudding all over the earth. According to plate-tectonics theory, as the Atlantic Ocean widened, the North American Plate was shoved into the Pacific Ocean Plate, which slipped under the western edge of the continent. The crust of western Montana, then at the leading edge of the continental plate, crumpled, cracked, and faulted as it rammed into the Pacific plate. The crust of Montana eventually over-rode the Pacific plate and was then lifted high above sea level. About 70 million years ago, the Rocky Mountains were produced by this collision of tectonic plates.
Some sedimentary layers, laid down with older strata topped by younger, were scrambled during these crustal collisions, and in some places older rocks were forced up from the geologic basement and slipped on top of younger ones. This is especially apparent in Glacier National Park . As the Rockies lifted, older layers of rocks skidded eastward from what are now the Flathead and North Fork Valleys, ending up as the Lewis Overthrust on the eastern front of the Rockies. Volcanic intrusions further developed the Rockies and formed separate mountain ranges to the east of them.
As western Montana lifted, ancient seas rolled back off the eastern part of the state for the final time. Swamps and floodplains stretched across eastern Montana by the end of the Mesozoic era, about 65 million years ago. Many plants and animals lived on these sedimentary flats, and their remains, as oil, go into our gas tanks today. Peat swamps were prevalent; eventually they crumbled and rotted into thick veins of coal.
Volcanoes began erupting in present-day Yellowstone National Park about 50 million years ago. A monumental eruption 600,000 years ago shot magma over the West, leaving a large crater, or caldera. Recurrent outpourings of lava formed the high plateau that’s there now.
Alternating wet and dry periods over the past 40 million years modified terrain all over the state. During dry spells, river valleys filled with sediments, nearly burying many mountain peaks. When the climate dampened, rivers washed away the fill to reexpose underlying structures. This deposit-erosion cycle has made eastern Montana a paleontologist’s dream. The largest complete tyrannosaurus skeleton on record was unearthed in remote Garfield County.
Cenozoic glaciers advanced south about 15,000 years ago. Valley glaciers ran down from northwestern Montana mountaintops and scoured out broad U-shaped valleys along their route. East of the divide, glaciers plowed the land flat as far south as the Missouri. The Beartooth Plateau, just north of Yellowstone National Park, was glacier-covered at much the same time lava was flowing over it. An ice dam in Idaho backed up the Clark Fork River until most of the valleys in western Montana were covered by glacial Lake Missoula. When the ice dam gave way, which it did repeatedly, torrents of water barreled across the Northwest, scouring topsoil and carving river gorges all the way to the Pacific coast.
East of the Rockies, glacial Lake Great Falls formed at the southern edge of the glacial sheet and reached from Great Falls to Cut Bank. Glacial ice forced the Missouri River, which originally emptied into Hudson’s Bay, to alter its course southward to the Mississippi; the Milk River now flows in a section of the Missouri’s original bed.