Terrorism is increasingly a problem across Africa, but as yet little work has sought to investigate its political effects. Studies in Europe and the US suggest that terrorist attacks can increase social and political trust, improve satisfaction with government, and may raise turnout. But it is unclear whether we should expect these findings to hold in a context where political institutions are often fragile, and where political violence is frequent. We investigate this question in Nigeria, where terrorism has been widespread and increasing over the past decade. Making use of unexpected attacks by the extremist group Boko Haram, which occurred during the fieldwork of a public opinion survey, we show that even in a context of weak state institutions and frequent terrorist activities terrorist attacks significantly increase political trust. Previous studies in other contexts have attributed such effects to a “rally round the flag” mechanism, whereby people look to national state institutions as the legitimate source of security in the face of terrorist threat. A further implication of this argument is that terrorism should result in a stronger sense of collective national identity. Counter to this, we find that terror attacks in this context actually reduce the salience of respondents’ national identity, instead significantly increasing ethnic identification. This fits with arguments from social psychology which suggest that fear and insecurity can lead people to identify more strongly with their in-group. These findings have important implications for understanding the political effects of terrorism in contexts where society is divided along ethnic lines and where ethnic divisions are politically salient.