Doping is a widely applied technological process in materials science that involves incorporating atoms or ions of appropriate elements into host lattices to yield hybrid materials with desirable properties and functions. For nanocrystalline materials, doping is of fundamental importance in stabilizing a specific crystallographic phase1, modifying electronic properties2, 3, 4, modulating magnetism5 as well as tuning emission properties6, 7, 8, 9. Here we describe a material system in which doping influences the growth process to give simultaneous control over the crystallographic phase, size and optical emission properties of the resulting nanocrystals. We show that NaYF4 nanocrystals can be rationally tuned in size (down to ten nanometres), phase (cubic or hexagonal) and upconversion10, 11, 12 emission colour (green to blue) through use of trivalent lanthanide dopant ions introduced at precisely defined concentrations. We use first-principles calculations to confirm that the influence of lanthanide doping on crystal phase and size arises from a strong dependence on the size and dipole polarizability of the substitutional dopant ion. Our results suggest that the doping-induced structural and size transition, demonstrated here in NaYF4 upconversion nanocrystals, could be extended to other lanthanide-doped nanocrystal systems for applications ranging from luminescent biological labels12 to volumetric three-dimensional displays13.