A mean-field-crystal-field theory is developed for random, multicomponent, anisotropic magnetic alloys. It is specially applicable to rare-earth alloys. A discussion is given of multicritical points and phase transitions between various states characterized by order parameters with different spatial directions or different ordering wave vectors. Theoretical predictions based on known parameters for the phase diagrams and magnetic moments for the binary rare-earth alloys of Tb, Dy, Ho, and Er, Tb-Tm, Nd-Pr, and pure double-hcp Nd agree qualitatively with the experimental observations. Quantitative agreement can be obtained by increasing the interaction between different alloy elements, in particular for alloys with very different axial anisotropy, e.g., Tb-Tm. A model system consisting of a singlet-singlet and singlet-doublet alloy is discussed in detail. A simple procedure to include fluctuation corrections in the mean-field results is also discussed.