It is a difficult and complicated subject.
wikipedia:
Two models for magnets: magnetic poles and atomic currents
Although for many purposes it is convenient to think of a magnet as having distinct north and south magnetic poles, the concept of poles should not be taken literally: it is merely a way of referring to the two different ends of a magnet. The magnet does not have distinct north or south particles on opposing sides. If a bar magnet is broken into two pieces, in an attempt to separate the north and south poles, the result will be two bar magnets, each of which has both a north and south pole.
Gilbert model
However, a version of the magnetic-pole approach is used by professional magneticians to design permanent magnets. In this approach, the pole surfaces of a permanent magnet are imagined to be covered with so-called magnetic charge, north-pole particles on the north pole and south-pole particles on the south pole that are the source of the magnetic field lines. If the magnetic-pole distribution is known, then the pole model gives the magnetic field H. Outside the magnet, the field B is proportional to H, while inside the magnetization must be added to H (see #Units and calculations, below, and demagnetizing field). This pole model is also called the Gilbert model of a magnetic dipole.[11] An extension of this method that allows for internal magnetic charges is used in theories of ferromagnetism (see micromagnetics).
Ampère model
Another model is the Ampère model, where all magnetization is due to the effect of microscopic, or atomic, circular bound currents, also called Ampèrian currents, throughout the material. For a uniformly magnetized cylindrical bar magnet, the net effect of the microscopic bound currents is to make the magnet behave as if there is a macroscopic sheet of electric current flowing around the surface, with local flow direction normal to the cylinder axis. (Since scraping off the outer layer of a magnet will not destroy its magnetic field, it can be seen that this is just a model, and the tiny currents are actually distributed throughout the material). The right-hand rule tells which direction the current flows. The Ampère model gives the exact magnetic field both inside and outside the magnet. It is usually difficult to calculate the Ampèrian currents on the surface of a magnet, whereas it is often easier to find the effective poles for the same magnet.
.