Modern day terrorism carried out by Muslims belonging to organizations like Al-Qaeda, or Al-Qaeda affiliated groups, has a context behind them. These groups often list their grievances or the causes behind their attacks, often pointing to western foreign policy issues, such as the invasions and interference in the Muslim world, like the war in Afghanistan, and Iraq etc.
In the recent case of Kenya, where a shopping mall was attacked by the Somali militant group al-Shabab, they cited Kenya’s military role in their country, for the reason behind their attack. So there is a context here, a real context, not the flimsy narrative put out there by the likes of Robert Spencer, that these attacks are merely carried out because these guys are Muslims, and Islam is a violent religion and so that’s the root cause of everything.
Now having said that, from an Islamic perspective, these groups still do not have a right to engage in the acts they’ve committed. Yes, what the west has done in some cases has been wrong, and there is a certain legitimate political grievance to be had with the continuing foreign presence in Afghanistan, the previous war in Iraq, the drone strikes that leave several civilians dead etc, but again from an Islamic perspective it still does not legitimize the actions carried out by Al-Qaeda like minded groups.
Islamically, two wrongs do not make a right, the Quran, and the hadiths have several texts that tell Muslims to not answer an evil with another evil. The Quran when speaking of war explicitly tells the Muslims to not cross the limits, and those limits are to not engage in indiscriminate slaughter, targeting innocent people, women and children, and so forth.
This is a very important to be made, because these groups seek to justify their actions by the fact that they may have a legitimate political grievance, but the crucial point is that just because you have a legitimate political grievance, does not give you an Islamic mandate to do whatever you feel like to try and correct or respond to that grievance or injustice.
Once these Muslim groups begin to engage in attacks that leave innocent people dead, they delegitimize themselves and their cause, in fact they become no better than those they’re supposedly fighting against.