The magnetocrystalline anisotropy (MCA) of bulk and thick films of FePt is calculated from a 'first-principles' theory. The starting point is a description from electronic density functional theory for systems of interacting electrons moving in lattices of ions. Relativistic effects such as spin-orbit coupling are included. FePt readily transforms into a CuAu-type (L1(0)) ordered phase and this coincides with the material's high anisotropy. Here we describe how to calculate the MCA of a partially ordered alloy and to extract its dependence on the long range chemical order parameter eta. We present calculations of the MCA of FePt as a function of eta and find excellent agreement with the experimental data of Okamoto et al (2002 Phys. Rev. B ...