The realization of the surface code for topological error correction is an essential step towards a universal quantum computer1,2,3. For single-atom qubits in silicon4,5,6,7, the need to control and read out qubits synchronously and in parallel requires the formation of a two-dimensional array of qubits with control electrodes patterned above and below this qubit layer. This vertical three-dimensional device architecture8 requires the ability to pattern dopants in multiple, vertically separated planes of the silicon crystal with nanometre precision interlayer alignment. Additionally, the dopants must not diffuse or segregate during the silicon encapsulation. Critical components of this architecture—such as nanowires9, single-atom transistors4 and single-electron transistors10–have been realized on one atomic plane by patterning phosphorus dopants in silicon using scanning tunnelling microscope hydrogen resist lithography11,12. Here, we extend this to three dimensions and demonstrate single-shot spin read-out with 97.9% measurement fidelity of a phosphorus dopant qubit within a vertically gated single-electron transistor with <5 nm interlayer alignment accuracy. Our strategy ensures the formation of a fully crystalline transistor using just two atomic species: phosphorus and silicon.