Resolving the spatial distribution of RNA and protein in tissues at subcellular resolution is a challenge in the field of spatial biology. We describe spatial molecular imaging, a system that measures RNAs and proteins in intact biological samples at subcellular resolution by performing multiple cycles of nucleic acid hybridization of fluorescent molecular barcodes. We demonstrate that spatial molecular imaging has high sensitivity (one or two copies per cell) and very low error rate (0.0092 false calls per cell) and background (~0.04 counts per cell). The imaging system generates three-dimensional, super-resolution localization of analytes at ~2 million cells per sample. Cell segmentation is morphology based using antibodies, compatible with formalin-fixed, paraffin-embedded samples. We measured multiomic data (980 RNAs and 108 proteins) at subcellular resolution in formalin-fixed, paraffin-embedded tissues (nonsmall cell lung and breast cancer) and identified >18 distinct cell types, ten unique tumor microenvironments and 100 pairwise ligand-receptor interactions. Data on >800,000 single cells and ~260 million transcripts can be accessed at http://nanostring.com/CosMx-dataset .