Sensory stimuli evoke neural activity that evolves over time. What features of these spatiotemporal responses allow the robust encoding of stimulus identity in a multistimulus environment? Here we examined this issue in the locust (Schistocerca americana) olfactory system. We found that sensory responses evoked by an odorant (foreground) varied when presented atop or after an ongoing stimulus (background). These inconsistent sensory inputs triggered dynamic reorganization of ensemble activity in the downstream antennal lobe. As a result, partial pattern matches between neural representations encoding the same foreground stimulus across conditions were achieved. The degree and segments of response overlaps varied; however, any overlap observed was sufficient to drive background-independent responses in the downstream neural population. Notably, recognition performance of locusts in behavioral assays correlated well with our physiological findings. Hence, our results reveal how background-independent recognition of odors can be achieved using spatiotemporal patterns of neural activity.