We present a simple algorithm, which we call the maximum overlap method (MOM), for finding excited-state solutions to self-consistent field (SCF) equations. Instead of using the aufbau principle, the algorithm maximizes the overlap between the occupied orbitals on successive SCF iterations. This prevents variational collapse to the ground state and guides the SCF process toward the nearest, rather than the lowest energy, solution. The resulting excited-state solutions can be treated in the same way as the ground-state solution and, in particular, derivatives of excited-state energies can be computed using ground-state code. We assess the performance of our method by applying it to a variety of excited-state problems including the calculation of excitation energies, charge-transfer states, and excited-state properties.