The Derjaguin approximation (DA) relates the force between curved surfaces to the interaction free energy between parallel planes. It is typically derived by considering the direct interaction between the bodies involved, thus treating the effect of an intervening solvent implicitly by a rescaling of the corresponding Hamaker constant. Here, we provide a generalization of DA to the case of a molecular medium between the bodies, as is the case in most applications. The derivation is based on an explicit statistical-mechanical treatment of the contribution to the interaction force from a molecular solvent using a general expression for intermolecular and molecule-surface interactions. Starting from an exact expression for the force, DA is arrived at by a series of well-defined approximations. Our results show that DA remains valid in a molecular solvent as long as (i) the surface-molecule interactions are of much shorter range than the radius R of the sphere and (ii) the density correlation length in the solvent is smaller than R. We then extend our analysis to the case where a phase transition occurs between the surfaces, which cannot easily be covered using a statistical-mechanical formalism due to the discontinuous change in the density of the medium. Instead using a continuum thermodynamic description, we show that this phase transformation induces an attractive force between the bodies, and that the force between curved surfaces can be related to the free energy in the corresponding planar case, in accordance with DA.