A new theory of cluster expansions has been derived, which allows one, for the first time, to estimate the energy of a disordered system from first principles. The cluster variables are derived from a series of density-functional calculations on ordered compounds. The disordering temperatures calculated with this theory show the correct trends for binary alloys of $4d$ transition metals, and are in excellent agreement with the experimental phase diagrams in most cases.