Graphene nanoribbons-narrow and straight-edged stripes of graphene, or single-layer graphite-are predicted to exhibit electronic properties that make them attractive for the fabrication of nanoscale electronic devices. In particular, although the two-dimensional parent material graphene exhibits semimetallic behaviour, quantum confinement and edge effects should render all graphene nanoribbons with widths smaller than 10 nm semiconducting. But exploring the potential of graphene nanoribbons is hampered by their limited availability: although they have been made using chemical, sonochemical and lithographic methods as well as through the unzipping of carbon nanotubes, the reliable production of graphene nanoribbons smaller than 10 nm with chemical precision remains a significant challenge. Here we report a simple method for the production of atomically precise graphene nanoribbons of different topologies and widths, which uses surface-assisted coupling of molecular precursors into linear polyphenylenes and their subsequent cyclodehydrogenation. The topology, width and edge periphery of the graphene nanoribbon products are defined by the structure of the precursor monomers, which can be designed to give access to a wide range of different graphene nanoribbons. We expect that our bottom-up approach to the atomically precise fabrication of graphene nanoribbons will finally enable detailed experimental investigations of the properties of this exciting class of materials. It should even provide a route to graphene nanoribbon structures with engineered chemical and electronic properties, including the theoretically predicted intraribbon quantum dots, superlattice structures and magnetic devices based on specific graphene nanoribbon edge states.