Single-cell RNA sequencing has revealed extensive molecular diversity in gene programs governing mammalian spermatogenesis but fails to delineate their dynamics in the native context of seminiferous tubules, the spatially confined functional units of spermatogenesis. Here, we use Slide-seq, a spatial transcriptomics technology, to generate an atlas that captures the spatial gene expression patterns at near-single-cell resolution in the mouse and human testis. Using Slide-seq data, we devise a computational framework that accurately localizes testicular cell types in individual seminiferous tubules. Unbiased analysis systematically identifies spatially patterned genes and gene programs. Combining Slide-seq with targeted in situ RNA sequencing, we demonstrate significant differences in the cellular compositions of spermatogonial microenvironment between mouse and human testes. Finally, a comparison of the spatial atlas generated from the wild-type and diabetic mouse testis reveals a disruption in the spatial cellular organization of seminiferous tubules as a potential mechanism of diabetes-induced male infertility.