Elemental phosphorus nanostructures are notorious for a large number of allotropes, which limits their usefulness as semiconductors. To limit this structural diversity, we synthesize selectively quasi-1D phosphorus nanostructures inside carbon nanotubes (CNTs) that act both as stable templates and nanoreactors. Whereas zigzag phosphorus nanoribbons form preferably in CNTs with an inner diameter exceeding 1.4 nm, a previously unknown square columnar structure of phosphorus is observed to form inside narrower nanotubes. Our findings are supported by electron microscopy and Raman spectroscopy observations as well as ab initio density functional theory calculations. Our computational results suggest that square columnar structures form preferably in CNTs with inner diameter around 1.0 nm, whereas black phosphorus nanoribbons form preferably inside CNTs with 4.1 nm inner diameter, with zigzag nanoribbons energetically favored over armchair nanoribbons. Our theoretical predictions agree with the experimental findings.Layered black phosphorus and the monolayer structure, dubbed phosphorene, 1 have attracted much attention due to their tuneable semiconducting character. 2 Phosphorus has a rich phase diagram that is still evolving. White/yellow phosphorus, 3, 4 consisting of P4 molecules, is a well