A magnet is made of any of a group of metals called ferromagnetic metals. Ferromagnetic metals contain many small magnetic fields called domains. In their natural state, the magnetic fields of these domains point in different directions. To create a magnet, the magnetic fields must align in the same direction.
Magnets are either temporary or permanent. The easiest type of magnet to make is a temporary magnet. Simply subjecting a ferromagnetic material to the magnetic field of an existing magnet causes its domains to align temporarily, producing a magnetic field that lasts for a short time after the original magnet is removed. Creating a permanent magnet involves heating ferromagnetic metal to a specific temperature, called the Curie temperature, causing the magnetic fields of individual domains to point in the same direction. Heating past the Curie temperature causes the material to become a permanent magnet.
An electromagnet uses electricity to temporarily magnetize a ferromagnetic metal, typically iron. Wrapping copper wire around an iron nail and connecting the wire to a battery creates a flow of electricity that aligns the magnetic domains.
A superconducting magnet, of use in MRI machines, utilizes metal alloys that conduct electricity well at extremely low temperatures. Cooling a loop of niobium and adding an electrical charge creates a very stable magnetic field.
There are magnetically "hard" materials, which remain magnetized, and magnetically "soft" materials, which lose their magnetism after a short time. Permanent magnets are commonly made from materials such as ferrite and alnico. These particular magnets are extremely difficult to demagnetize. This is because they have high coercivity whereas "soft" magnets have low coercivity.