Electricity and magnetism are intimately related and somewhat similar in that both are capable of attraction or repulsion at a distance, and electricity is the cause of magnetism. Specifically, magnetic fields always and only arise in response to an electric current, which is really just electrons in motion. According to Georgia State University, this can be a large current or tiny, such as electrons moving in their atomic orbitals.
Any movement of electrons constitutes an electric current, and any electric current produces a magnetic field. This even holds for permanent magnets. In this case, it is the movement of electrons in a particular orientation relative to their orbitals that leads to the permanent magnetic effect. This actually takes place in all atoms, but it is only in ferromagnetic metals where the orientations of all the atoms in the object can be aligned with one another. In other materials and in unmagnetized ferromagnetic materials, these are random, so any magnetic field produced by one atom is canceled out by its neighbors.
Both electric and magnetic forces can be either attractive or repulsive. The electric force arises as a result of similar or opposite charges, where like charges repel and opposite charges attract. With magnetism, like poles repel and opposite poles attract. The actual mechanism of magnetic force is still not well understood.