When densities of matter approach these limits, it is called 'degenerate'. The ideal gas law no longer applies. For degenerate matter, the pressure depends only on density, and not on temperature. Heisenberg Uncertainty Principle States that one cannot simultaneously know exactly where a particle is and also how fast it is moving. This motion leads to collisions.
Collisions translate to pressure, and so gravitational contraction can be halted.
White Dwarf stars resist gravitational collapse via electron degeneracy pressure. If gravity is too strong, electrons are forced into the nuclus with the protons. These combine to make neutrons. Neutron stars resist gravitational collapse via neutron degeneracy pressure.