The minimization of molecular potential energy functions is one of the most challenging, unsolved nonconvex global optimization problems and plays an important role in the determination of stable states of certain classes of molecular clusters and proteins. In this paper, some equivalent formulations and necessary optimality conditions for the minimization of the Lennard–Jones potential energy function are presented. A new strategy, the code partition algorithm, which is based on a bilevel optimization formulation, is proposed for searching for an extremal Lennard–Jones code. The convergence of the code partition algorithm is proved and some computational results are reported.