A generalized adiabatic connection for ensembles (GACE) is presented. In contrast to the traditional adiabatic connection formulation, both ensemble weights and interaction strength can vary along a GACE path while the ensemble density is held fixed. The theory is presented for non-degenerate two-state ensembles but it can in principle be extended to any ensemble of fractionally occupied excited states. Within such a formalism an exact expression for the ensemble exchange-correlation density-functional energy, in terms of the conventional ground-state exchange-correlation energy, is obtained by integration over the ensemble weight. Stringent constraints on the functional are thus obtained when expanding the ensemble exchange-correlation energy through second order in the ensemble weight. For illustration purposes, the analytical derivation of the GACE is presented for the H 2 model system in a minimal basis, leading thus to a simple density-functional approximation to the ensemble exchange-correlation energy. Encouraging results were obtained with this approximation for the description in a large basis of the first 1 Σ + g excitation in H 2 upon bond stretching. Finally, a range-dependent GACE has been derived, providing thus a pathway to the development of a rigorous state-average multi-determinant density-functional theory.