High-density packing in organic crystals is usually associated with an increase of the coordination between molecules. Such a concept is not necessarily extended to two-dimensional molecular networks self-assembled on a solid surface, for which we demonstrate the key role of the surface in inducing the optimal packing. By a combination of scanning tunneling microscopy experiments and multiscale computer simulations, we study the phase transition between two polymorphs. We find that, contrary to intuition, the structure with the lowest packing fraction corresponds to the highest molecular coordination number, due to the competition between surface and intermolecular forces. Having the lowest free energy, this structure spreads out as the most stable polymorph over a wide range of molecular concentrations.