Spatial variation in cellular phenotypes underlies heterogeneity in immune recognition and response to therapy in cancer and many other diseases. Spatial transcriptomics (ST) holds the potential to quantify such variation, but existing analysis methods address only a small part of the analysis challenge, such as spot deconvolution or spatial differential expression. We present BayesTME, an end-to-end Bayesian method for analyzing spatial transcriptomics data. BayesTME unifies several previously distinct analysis goals under a single, holistic generative model. This unified approach enables BayesTME to (i) be entirely reference-free without any need for paired scRNA-seq, (ii) outperform a large suite of methods in quantitative benchmarks, and (iii) uncover a new type of ST signal: spatial differential expression within individual cell types. To achieve the latter, BayesTME models each phenotype as spatially adaptive and discovers statistically significant spatial patterns amongst coordinated subsets of genes within phenotypes, which we term spatial transcriptional programs. On human and zebrafish melanoma tissues, BayesTME identifies spatial transcriptional programs that capture fundamental biological phenomena like bilateral symmetry, differential expression between interior and surface tumor cells, and tumor-associated fibroblast and macrophage reprogramming. Our results demonstrate BayesTME's power in unlocking a new level of insight from spatial transcriptomics data and fostering a deeper understanding of the spatial architecture of the tumor microenvironment. BayesTME is open source and publicly available (https://github.com/tansey-lab/bayestme).