We prove rigorously that the exact N-electron Hohenberg-Kohn density functional converges in the strongly interacting limit to the strictly correlated electrons (SCE) functional, and that the absolute value squared of the associated constrained-search wavefunction tends weakly in the sense of probability measures to a minimizer of the multi-marginal optimal transport problem with Coulomb cost associated to the SCE functional. This extends our previous work for N=2 [CFK11]. The correct limit problem has been derived in the physics literature by Seidl [Se99] and Seidl, Gori-Giorgi and Savin [SGS07]; in these papers the lack of a rigorous proof was pointed out. We also give a mathematical counterexample to this type of result, by replacing the constraint of given one-body density -- an infinite-dimensional quadratic expression in the wavefunction -- by an infinite-dimensional quadratic expression in the wavefunction and its gradient. Connections with the Lawrentiev phenomenon in the calculus of variations are indicated.