Gravity plays a crucial role in the equilibrium of stars by balancing the outward pressure from nuclear fusion against the inward pull of gravity. This fusion process begins when a star accumulates enough mass, leading to the fusion of hydrogen into heavier elements, which generates heat. As stars lose mass over time, gravity's ability to maintain stability diminishes, potentially resulting in phenomena such as novas or supernovas. Additionally, gravity is essential in the formation of planets, as it causes dust and gas in protoplanetary disks to coalesce into larger bodies. Overall, gravity is fundamental in both star stability and the formation of planetary systems.