Lithium metal is an attractive anode material for rechargeable batteries, owing to its high theoretical specific capacity of 3,860 mAh g−1. Despite extensive research efforts, there are still many fundamental challenges in using lithium metal in lithium-ion batteries. Most notably, critical information such as its nucleation and growth behaviour remains elusive. Here we explore the nucleation pattern of lithium on various metal substrates and unravel a substrate-dependent growth phenomenon that enables selective deposition of lithium metal. With the aid of binary phase diagrams, we find that no nucleation barriers are present for metals exhibiting a definite solubility in lithium, whereas appreciable nucleation barriers exist for metals with negligible solubility. We thereafter design a nanocapsule structure for lithium metal anodes consisting of hollow carbon spheres with nanoparticle seeds inside. During deposition, the lithium metal is found to predominantly grow inside the hollow carbon spheres. Such selective deposition and stable encapsulation of lithium metal eliminate dendrite formation and enable improved cycling, even in corrosive alkyl carbonate electrolytes, with 98% coulombic efficiency for more than 300 cycles.