When the most massive stars die, they collapse under their own gravity and leave black holes; when stars that are a little less massive than this one die, they explode and leave behind dense, dead remnants of stars called neutron stars. Neutron stars form when a massive star runs out of fuel and collapses. In the central region of the star, the nucleus collapses, crushing every proton and electron into a neutron. If the core of the collapsing star has between 1 and 3 solar masses, these newly created neutrons can stop the collapse and leave behind a neutron star.
Stars with higher masses will continue to collapse into stellar-mass black holes. These stellar remnants measure about 20 kilometers (12.5 miles) in diameter. A sugar cube of neutron star material would weigh about 1 trillion kilograms (or a billion tons) on Earth, almost as much as a mountain. Stellar black holes emerge as a final stage in the evolution of massive stars.
The star must have a mass at least ten times greater than the mass of the Sun. This ensures that, after all the nuclear fuel has been consumed and the star explodes and the outer layers are detached, there is still enough mass in its core with sufficient gravity to collapse into a black hole. The most massive stars only have masses up to about 500 solar masses; otherwise, they are not stable. It means that the most massive black hole of stellar origin can also have a mass of a few hundred solar masses.
A handful of neutron stars have been found sitting at the centers of supernova remnants that silently emit X-rays. Billions of years passed, the universe expanded and the slightly larger black holes grew by continuously merging with smaller ones to form enormous masses. In binary systems, some neutron stars can be found accumulating materials from their companions, emitting electromagnetic radiation driven by the gravitational energy of the material that accumulates. In all neutron stars, the star's crust is bound to the magnetic field, so that any change in one affects the other.
When the first stars were created from abundant dense clouds of hydrogen and helium in the early universe, they had masses of hundreds of solar masses. In a magnetar, with its enormous magnetic field, the movements of the crust cause the neutron star to release a large amount of energy in the form of electromagnetic radiation. For a short period of time (it's brief from the point of view of the star's age, but it can last for millions of years), before it also explodes as a supernova, it will increase in size and lower its surface temperature. Black holes were larger and more numerous where the original gas cloud was heavier and smaller and less abundant where the birth cloud was scarcer.
There are stellar-mass black holes that have masses of a few to, at most, several tens of the mass of the Sun. Often, the magnetic field is not aligned with the axis of rotation, so those bundles of particles and light travel as the star rotates.