When star is no longer able to fuse atoms in its core, it explodes in what we call supernova and its core collapses. Depending on the mass of the star, as it reaches the end of its life, it will end up as white dwarf, neutron star or stellar black hole.
After the supernova of the large star, with main-sequence mass of above 10 solar masses, the outer layers are ejected into space and the core shrinks. What's left is a neutron star with the diameter of about 10 kilometers and mass between 1.4 and 3 times that of the Sun. This makes them the densest stars in the universe with extremely strong gravitational pull. This has several consequences.
Because of the high gravity, electrons are no longer able to orbit protons, so they merge and create neutrons. Neutrons are prevailing particle, although outer layers, where the gravity is lower, are thought to be made of iron atoms, with nuclei made of both protons and neutrons.
After the collapse, the neutron star keeps the angular momentum of the original star. This means that it keeps spinning, but due to extremely small diameter, slow rotation of the original star's core translates into a really fast rotation of the neutron star. We are talking from several times per second to several hundred times per second. Good analogy would be an ice skater who first spins with their arms stretched out and then pulls their arms in, thus beginning to rotate faster with the same mass but more compact figure.
Rapidly spinning sphere with iron at its surface creates a strong magnetic field around the neutron star. Via this field, the star emits radiation and loses energy over time. Eventually it stops spinning.
Since the fusion process is no longer underway, neutron stars don't shine, but they are still detectable because they affect their surroundings by gravitational lensing and the effect they have on their companions in binary systems.
A type of neutron star that we can see is called pulsar – a pulsating star. Pulsars are visible because they emit beams of electromagnetic radiation from their poles at regular intervals. Well, we see them at regular intervals. Imagine a lighthouse and how we see its light every couple of moments.
Pulsar's strong magnetic field directs the electromagnetic radiation in such manner that it is emitted from star's magnetic poles. It is important to note that the magnetic axis and star's rotational axis must not be aligned. If they were aligned, we'd either see this radiation (i.e. one magnetic pole) all the time or never if its not directed towards us. With magnetic and rotational axis misaligned, we see one magnetic pole in intervals.
There are three types of pulsars:
Arguably, all neutron stars are or were pulsars at one point in their life, but in the universe 13.8 billion years old, most of the neutron stars don't pulsate anymore.