A magnetar is a type of supernova remnant; specifically, a neutron star with an extremely intense magnetic field. Magnetars underlie observed astronomical phenomena such as soft gamma repeaters and anomalous x-ray pulsars. Tensions in the magnetar's crust periodically cause "starquakes" and release electromagnetic radiation in the form of x-rays, producing pulses about every ten seconds which can be observed by astronomers on Earth. At irregular and longer intervals, gamma rays are also released.
Magnetars are created when a supergiant star runs out of nuclear fuel and collapses catastrophically as a supernova. For a magnetar to be produced, the star must have a fast rotational speed and magnetic field prior to the collapse. This happens in only about 1 out of 10 cases. Depending on the star's mass, a neutron star or black hole is left over as the supernova remnant.
If the supergiant star is rotating very quickly as it collapses, and it isn't so massive, it collapses into a black hole, an intense natural dynamo is created in the interior of the resulting neutron star. If the neutron star is rotating fast enough to keep up with the period of convection (about once every ten milliseconds), convection currents are able to operate globally, transferring a significant amount of kinetic energy to a magnetic field. This is the same principle of operation as electrical generators, which rotate a coiled wire in the presence of a magnetic field to generate electricity. It is thought that most of the field-building is done in the first 10 seconds the neutron star is created.
Through this mechanism, the already awesome magnetic field strength of a typical neutron star, 108 teslas, is boosted to as high as 1011 teslas. By comparison, the magnetic field strength of the Earth is 30-60 microteslas. The magnetic strength field of a neodymium magnet is about 1 tesla, with a magnetic energy density of 4.0 x 105 J/m3. Meanwhile, a magnetar can have a magnetic energy density as high as 100 gigateslas, an energy density of 4.0 x 1016 J/m3, with an E/c2 mass density >105 times that of lead.
A magnetar's space-bending magnetic field does not last long in astronomical terms — only about 10,000 years, then it declines to that of an average neutron star. At this point, their starquakes and gamma ray emission behaviors cool down. Given their short lifetimes, we only see about nine magnetars in our own galaxy.
The magnetic field generated by a magnetar is truly mind-boggling. Its magnetic field is so intense, a magnetar 160,000 km (100,000 mi) distant could wipe every credit card on Earth. At less than 1,000 km distance, the magnetar could rip apart flesh, because of the brief magnetic fluctuations within its water molecules. Close to the magnetar, x-rays and other electromagnetic radiation splits apart into two or merges. This phenomenon can be observed in a calcite crystal and is called birefringence. Matter itself is stretched: in a field strength of 105 teslas, an atomic orbital will deform into a shape somewhat like cigars. At 1010 teslas, hydrogen atoms become like pieces of spaghetti 200 times narrower than their normal diameters.