The force that opposes gravity and prevents objects from collapsing on themselves is primarily known as the electromagnetic force. This force arises from the interaction between electrically charged particles, such as electrons and protons.
At the atomic and molecular level, electromagnetic forces come into play due to the interactions between the negatively charged electrons orbiting the positively charged atomic nuclei. These forces result in the stability of matter and prevent it from collapsing under its own gravitational attraction.
The electromagnetic force is significantly stronger than gravity at small distances, which is why it dominates interactions between charged particles within atoms and molecules. This force, along with the repulsion between electrons due to their like charges, provides the necessary counterbalance to gravity, maintaining the structural integrity of solid objects and preventing their collapse.