Neutron stars are formed when massive stars exhaust their nuclear fuel and undergo a supernova explosion. During the explosion, the outer layers of the star are ejected into space, while the core collapses under its own gravity. If the core's mass is between about 1.4 and 3 times the mass of the Sun, it will collapse into a neutron star.
Neutron stars are composed primarily of densely packed neutrons, with a thin crust of lighter elements such as iron and hydrogen. Beneath the crust lies a superfluid neutron "soup" where the neutrons flow without any friction, and a solid core of extremely densely packed neutrons at the center.