The precise measurement of mechanical stress at the nanoscale is of fundamental and technological importance. In principle, all six independent variables of the stress tensor, which describe the direction and magnitude of compression/tension and shear stress in a solid, can be exploited to tune or enhance the properties of materials and devices. However, existing techniques to probe the local stress are generally incapable of measuring the entire stress tensor. Here, we make use of an ensemble of atomic-sized in situ strain sensors in diamond (nitrogen-vacancy defects) to achieve spatial mapping of the full stress tensor, with a submicrometer spatial resolution and a sensitivity of the order of 1 MPa (10 MPa) for the shear (axial) stress components. To illustrate the effectiveness and versatility of the technique, we apply it to a broad range of experimental situations, including mapping the stress induced by localized implantation damage, nanoindents, and scratches. In addition, we observe surprisingly large stress contributions from functional electronic devices fabricated on the diamond and also demonstrate sensitivity to deformations of materials in contact with the diamond. Our technique could enable in situ measurements of the mechanical response of diamond nanostructures under various stimuli, with potential applications in strain engineering for diamond-based quantum technologies and in nanomechanical sensing for on-chip mass spectroscopy.