Perception is often the expected outcome of our actions, while at other times it emerges from unexpected changes in the scene. During spatial navigation, animals must differentiate between cues generated by self-motion from motion that originated externally. To reveal the neural basis of this perceptual ability, we examined the midbrain superior colliculus (SC), which contains an egocentric map of sensorimotor space. By simulating whisker-guided navigation through a dynamic landscape, we discovered a transient neural response that selectively emerged for unexpected, externally generated tactile motion. This transient response only emerged when external motion engaged different whiskers, arguing that sensorimotor predictions are specific to a somatotopic location. When external motion engaged the same whiskers, neurons encoded surface motion with shifts in spike timing correlated to self-generated tactile features. Thus, a persistent representation of self-generated touch may be necessary to encode spatial features finer than the receptor array. In conclusion, the SC contains complementary rate and temporal codes to differentiate external from self-generated spatial features during tactile localization.