A bar magnet is a seemingly ordinary piece of metal from which invisible magnetic field lines originate. These magnetic field lines effect any magnetic material in the vicinity of the magnet. Magnets have a north pole where, by convention, magnetic lines of force point outward and a south pole where they point inward. Opposite poles attract each other; while similar poles repel each other. A toy bar magnet has a magnetic field (~1000 Oersted) thousands of times larger than the Earth’s surface magnetic field(~1/4 Oersted) and about the strength of the field found in sunspots on the solar surface.
All magnetic fields are the result of moving electric charges. In the case of solid materials, the moving charges are the individual electrons rotating about the atomic nuclei. However, that would not be sufficient to produce a magnetic field because the orbiting electrons are randomly oriented and their individual magnetic fields cancel out. In a permanent magnet, the fields of the individual atoms are all lined up so that they add rather than cancel each other out.
source: windows to the universe