Modifying material properties at the nanoscale is crucially important for devices in nanoelectronics, nanophotonics and quantum information. Optically active defects in wide band gap materials, for instance, are vital constituents for the realisation of quantum technologies. Yet, the introduction of atomic defects through direct ion implantation remains a fundamental challenge. Herein, we establish a universal method for material doping by exploiting one of the most fundamental principles of physics - momentum transfer. As a proof of concept, we direct-write arrays of emitters into diamond via momentum transfer from a Xe+ focused ion beam (FIB) to thin films of the group IV dopants pre-deposited onto a diamond surface. We conclusively show that the technique, which we term knock-on doping, can yield ultra-shallow dopant profiles localized to the top 5 nm of the target surface, and use it to achieve sub-50 nm lateral resolution. The knock-on doping method is cost-effective, yet very versatile, powerful and universally suitable for applications such as electronic and magnetic doping of atomically thin materials and engineering of near-surface states of semiconductor devices.