The magnetic field is created by moving electric charges, which combine to produce a magnetic field when a significant number of unpaired electrons with their spin aligned in the same direction.
The Lorentz force is exerted by the magnetic field on the particles that are retained in the magnetic field.