Galaxies form gradually, over billions of years. Tiny differences in density in the early universe were amplified by gravity, dark matter gathered into large structures called halos, and ordinary gas fell into those halos, cooled and formed stars. Small early galaxies then grew by collecting more gas, forming new stars and merging with other galaxies. No galaxy appeared fully formed, and galaxy evolution is still happening across the universe today.
Quick answers
– What galaxies are made of: Stars, gas and dust, surrounded by a halo of dark matter, and often with a supermassive black hole at the center.
– How they form: Gravity amplifies early density differences, dark matter halos gather gas, the gas cools into stars, and small systems merge into larger ones.
– What shapes them: Gas supply, mergers, star formation, black hole and supernova feedback, and environment.
How Galaxies Form, Step by Step
- Tiny density differences exist in the early universe, with some regions holding slightly more matter.
- Gravity amplifies them. A denser region pulls in more matter, which strengthens its gravity further.
- Dark matter gathers into halos, which become important gravitational wells.
- Gas falls in, cools and becomes dense. Ordinary matter follows the gravity of the halos.
- The first stars form, and small protogalaxies develop.
- Galaxies grow by collecting more gas, forming new stars and merging.
- Supernovae and black holes reshape them, and over billions of years a wide variety of galaxies appears.
What Are Galaxies Made Of?
Look at the night sky and you see only a small part of something much larger. Our Sun belongs to the Milky Way, a galaxy with hundreds of billions of stars, and the Milky Way is one of an enormous number of galaxies in the observable universe. Some are spirals, others are elliptical or irregular, some are rich in young stars and active star formation, and others hold mostly older stars. The Milky Way, for example, has a large rotating disk of stars, gas and dust, a much larger dark matter halo, a dense central bulge and a supermassive black hole called Sagittarius A*.
How Did the First Structures Form?
After the Big Bang the universe was extremely hot and dense, and as it expanded it cooled. Eventually atoms formed and the universe became transparent to light. But it was not perfectly uniform. Some regions held slightly more matter than others, and gravity could amplify those small differences. A region with slightly more matter pulled in more matter, which strengthened its gravity, and over enormous stretches of time small differences grew into large structures, including the places where galaxies formed. See how this fits into cosmic history in how the universe began.
What Role Does Dark Matter Play? What Is the Cosmic Web?

Dark matter does not emit, absorb or reflect light the way ordinary matter does, so astronomers cannot see it directly. Its gravity reveals it. As the universe evolved, dark matter gathered into large structures called halos, which became key gravitational environments for galaxy formation. Ordinary matter responded to the same gravity: gas was pulled into these wells, accumulated, became denser and eventually cooled enough for stars to form. Exactly what dark matter is remains unknown.
On much larger scales, galaxies are not scattered randomly. They tend to sit in dense regions linked by huge filaments, while vast low-density regions called voids hold relatively few galaxies. Together these structures form the cosmic web. Dark matter plays a major role in creating this network, and galaxies develop in its denser parts and keep interacting with their surroundings as they evolve.
How Did the First Galaxies Form?
The early universe held mostly hydrogen and helium and very few heavier elements. Gas gathered inside dark matter halos under gravity. As it became denser it could radiate energy and cool, and eventually some regions became dense enough for collapse to continue. The first stars formed. They were probably very different from the Sun, and some may have been extremely massive and short-lived. When they died, their radiation affected nearby gas and their explosions released heavier elements, so the universe began to become chemically enriched. Small systems of dark matter, gas and stars developed into primitive galaxies, which became building blocks for larger ones.
How Do Galaxies Grow?

Galaxy formation is not a single event. A galaxy can grow by collecting more gas, forming new stars and merging with other galaxies. Picture a small protogalaxy of dark matter, gas and stars: over time more gas can fall in, and smaller galaxies can interact with it or merge with it, again and again. This is why galaxy formation is called hierarchical. Large galaxies can contain stars and material that came from smaller systems that merged long ago.
How gas becomes stars. Stars form from ordinary matter, and gas must become dense enough for gravity to overcome the forces resisting collapse. As gas falls into a developing galaxy it gains energy and can become hot, but it can also radiate energy away and cool, and cooled gas can settle toward the center. Gas carrying angular momentum can begin to rotate around the developing galaxy, and under suitable conditions it can settle into a rotating disk. Dense clouds within that disk can then collapse to form stars, as described in how stars are born. A galaxy is not just a collection of stars. It is the environment in which new generations of stars keep forming.
What Determines a Galaxy’s Shape? Spiral, Elliptical and Irregular

No single process decides whether a galaxy becomes spiral, elliptical or irregular. Its mass, gas supply, environment, mergers, star formation and feedback all contribute.
- Spiral galaxies form when gas settles into a rotating disk. Stars form in dense regions of that disk, young massive stars light up the surrounding gas, and supernovae return energy and material. The spiral pattern is dynamic: stars orbit the galaxy, gas moves through the disk, and the structure can involve density waves and other changing processes. A spiral may look organized from far away, but it is a constantly changing system.
- Elliptical galaxies are generally smoother and rounder, with mostly older stars and relatively little cold gas. Mergers can contribute to these more spheroidal shapes. When two galaxies approach, their gravity distorts their shapes, gas clouds collide and star formation changes, and they can eventually merge. A major merger of disk galaxies can produce a more spheroidal remnant, and repeated mergers can contribute to massive ellipticals. But mergers are only part of the explanation, since gas supply, star formation, feedback, black hole activity, mass and environment also matter.
- Irregular galaxies can be distorted by gravitational interactions, especially smaller ones.
A galaxy’s shape is partly a record of what it has experienced.
How Do Black Holes and Supernovae Shape Galaxies?
Supermassive black holes. Many large galaxies have one at the center. When it actively accretes gas, the surrounding region can release enormous energy, and radiation and jets can affect nearby gas. This produces feedback, which can heat gas or drive outflows and influence how much material is left for future star formation. The relationship between galaxies and their central black holes is complex, and exactly how supermassive black holes grow is still an active area of research.
Supernovae. Massive stars eventually die, and their explosions return energy and material to their surroundings. Supernovae can heat gas, drive outflows, compress nearby clouds and spread heavier elements. Depending on the environment, this can encourage new star formation or make it harder for gas to collapse. They also enrich the interstellar medium with material from earlier generations of stars. See how supernovae work.
Why some galaxies stop forming stars. A galaxy needs cool gas to keep forming stars. If its gas supply falls, star formation can slow. Gas can also be pushed out, become too hot to collapse, or be affected by the galaxy’s environment, and supernovae and active black holes can add energy. A galaxy in a dense cluster can face very different conditions from an isolated one. When several of these combine, a galaxy can become quiescent, with little star formation, while others keep abundant cold gas and go through intense bursts of star formation, which are called starburst galaxies.
How Do Galaxy Clusters Fit In?
Galaxies rarely exist alone. They can gather into groups, and groups can grow into galaxy clusters that hold hundreds or thousands of galaxies inside enormous dark matter halos. The space between the galaxies can contain extremely hot gas. Clusters sit in dense regions of the cosmic web and can be linked to other dense regions by huge filaments. This shows the hierarchy of cosmic structure: stars exist within galaxies, galaxies gather into groups and clusters, and clusters are part of the cosmic web. The same gravitational process works across these scales.
How Can Astronomers See Galaxies in the Past?

Light takes time to travel, so when astronomers observe a distant galaxy, they see it as it was when its light began its journey. A galaxy billions of light-years away is seen at a much earlier stage of its history, and comparing galaxies at different distances lets astronomers compare different stages of cosmic evolution. Some distant galaxies look smaller, more irregular or more actively star-forming than many mature galaxies nearby, and the James Webb Space Telescope has let astronomers study galaxies from very early in cosmic history.
No single kind of light shows everything about a galaxy. Visible light shows stars, infrared can show older stellar populations and regions partly hidden by dust, radio can reveal cold gas, and X-rays can reveal extremely hot gas and energetic activity from black holes. Combining them gives a more complete picture: stars tell one part of a galaxy’s history, gas another, and dust, black hole and energetic processes tell still more.
How Did the Milky Way Form? Will It Merge With Andromeda?
The Milky Way was not created in its present form. It assembled gradually from smaller structures: gas accumulated, stars formed, older stellar populations joined the growing galaxy, its disk and central regions developed, and its dark matter halo kept growing. The process has not stopped. The Milky Way interacts with smaller satellite galaxies and keeps forming stars from available gas, and it is approaching the Andromeda Galaxy. Whether the two galaxies will ultimately collide or merge remains uncertain. A 2025 analysis using Hubble and Gaia data estimated roughly a 50% chance of a collision within the next 10 billion years.
So there is no single moment when galaxy formation ends. Every galaxy’s stars, gas, dust, shape, black hole and position in the cosmic web hold clues to how it formed and changed.
Key Takeaways
- Galaxies formed from tiny density variations in the early universe, which gravity amplified into large structures.
- Dark matter halos provided the gravitational framework, and gas that cooled inside them formed stars.
- Galaxies grow through gas accretion, star formation and mergers.
- Spiral and elliptical galaxies develop different structures because of their gas, mergers, star formation, feedback and history.
- Supernovae and supermassive black holes can influence galaxy evolution by changing the surrounding gas.
- Galaxies live in the cosmic web of filaments, clusters and voids, and their evolution continues today.
A galaxy is the visible result of billions of years of gravity, matter, star formation and cosmic evolution, and every galaxy carries a record of how the universe built it.
Keep Reading
- How did the universe begin? The science behind the Big Bang
- How are stars born? The science behind star formation
- How do supernovae work? The science behind stellar explosions
- Explore more evidence-based explanations in CAVELYRA’s Science Explained collection.
References
- NASA Science. Galaxy Evolution. Background on galaxy formation, mergers, collisions and evolution.
- NASA Goddard Space Flight Center. The Hidden Lives of Galaxies: Formation of Galaxies. Explains early matter clumps, protogalaxies, gas cooling and dark matter halos.
- NASA Science. Galaxies Over Time. Webb observations of early galaxies and the role of dark matter in galaxy evolution.
- NASA. Mapping the Universe’s Earliest Structures with COSMOS-Webb. Research context for early structures and dark matter halos.
- NASA Hubble Mission Team. Apocalypse When? Hubble Casts Doubt on Certainty of Galactic Collision. June 2, 2025. Updated assessment of the Milky Way–Andromeda collision likelihood.
