The first hyperpolarizability and electronic excitation spectrum of sesquifulvalene and a sesquifulvalene ruthenium complex have been computed and analyzed with use of time-dependent density-functional theory. A new orbital decomposition scheme is introduced that allows the computed first hyperpolarizability to be related to the electronic structure of complex molecules. The analysis shows that the first hyperpolarizability of sesquifulvalene is not associated with the first intense absorption, with HOMO → LUMO+1 character, but is dominated by the lowest energy transition, with HOMO → LUMO character, despite its very low intensity. In the ruthenium complex, the analysis reveals that the strong enhancement of the nonlinear optical response compared to free sesquifulvalene should not be attributed to the effect of complexation on the hyperpolarizability of sesquifulvalene. The strong hyperpolarizability originates from MLCT transitions from ruthenium d-orbitals to an empty orbital located at the seven ring of sesquifulvalene, transitions that have no analogue in free sequifulvalene. © 2006 American Chemical Society.