We study the role of perceived threats from other cultures induced by terrorist attacks and criminal events on public discourse and support for radical right parties. We develop a rule which allocates Twitter users to electoral districts in Germany and use a machine learning method to compute measures of textual similarity between the tweets they produce and tweets by accounts of the main German parties. Using the exogenous timing of attacks, we find that, after an event, Twitter language becomes on average more similar to that of the main radical right party, AfD. The result is driven by a larger share of tweets discussing immigrants and Muslims, common AfD topics, and by a more negative sentiment of these tweets. Shifts in language similarity are correlated with changes in vote shares between federal elections. These results point to the role of perceived threats from minorities on the success of nationalist parties.