Diamagnetism
Any time two electrons share the same orbital, their spin quantum numbers have to be different. In other words, one of the electrons has to be "spin-up," with
Think of spins as clockwise and counterclockwise. If one spin is clockwise and the other is counterclockwise, then the two spin directions balance each other out and there is no leftover rotation. Note what all of this means in terms of electrons sharing an orbital: Since electrons in the same orbital always have opposite values for their spin quantum numbers (ms), they will always end up canceling each other out. In other words, there is no leftover spin in an orbital that contains two electrons.
Electron spin is very important in determining the magnetic properties of an atom. If all of the electrons in an atom are paired up and share their orbital with another electron, then the total spin in each orbital is zero and the atom is diamagnetic. Diamagnetic atoms are not attracted to a magnetic field, but rather are slightly repelled.
Diamagnetic levitation
A small (~6mm) piece of pyrolytic graphite (a material similar to graphite) levitating over a permanent gold magnet array (5mm cubes on a piece of steel). Note that the poles of the magnets are aligned vertically and alternate (two with north facing up, and two with south facing up, diagonally).
Paramagnetism
Electrons that are alone in an orbital are called paramagnetic electrons. Remember that if an electron is alone in an orbital, the orbital has a net spin, because the spin of the lone electron does not get canceled out. If even one orbital has a net spin, the entire atom will have a net spin. Therefore, an atom is considered to be paramagnetic when it contains at least one paramagnetic electron. In other words, an atom could have 10 paired (diamagnetic) electrons, but as long as it also has one unpaired (paramagnetic) electron, it is still considered a paramagnetic atom.
Just as diamagnetic atoms are slightly repelled from a magnetic field, paramagnetic atoms are slightly attracted to a magnetic field. Paramagnetic properties are due to the realignment of the electron paths caused by the external magnetic field. Paramagnets do not retain any magnetization in the absence of an externally applied magnetic field, because thermal motion randomizes the spin orientations. Stronger magnetic effects are typically only observed when d- or f-electrons are involved. The size of the magnetic moment on a lanthanide atom can be quite large, as it can carry up to seven unpaired electrons, in the case of gadolinium(III) (hence its use in MRI).