The facultative intracellular pathogen Salmonella enterica serovar Typhimurium faces multiple environments during infection, including different cell types as well as extracellular fluids. We propose that Salmonella ascertains its cellular location by assessing the Mg2+ concentration of its milieu. A signal transduction system, PhoP/PhoQ, signals Salmonella its presence in a intracellular (low Mg2+) or extracellular (high Mg2+) environment, thereby promoting transcription of genes required for survival within or entry into host cells. The PhoP/PhoQ system is high in a regulatory hierarchy that controls other signal transduction systems that respond to different host cues, enabling the microorganism to determine its precise tissue and cellular location.