Bismillah(In the name God), Alhamdulillah(All praise is to Allah), and may peace and blessings be upon the final prophet and messenger, Muhammad(saw),
Alright, I am a Sunni Muslim who adheres to the manhaj, methodology, and understanding of the Salaf As Saliheen(the pious predecessors who understood the religion better than any of us), and I am writing this post to shed some light on this matter from an Islamic Perspective insha Allah so that non-muslims and the muslims(who may not have much insight or knowledge regarding this matter) can understand.
Regarding, the Sri Lanka attacks, it was an attack carried by the group that calls itself the the Islamic State or Daesh, or Dawlatul Islamiyah in Arabic. Their official media has confirmed this and they have posted a video showing the suicide bombers pledging allegiance to the so called "Ameer Ul Mu3mineen" or "Khalifah ul Muslimeen" called Abu Bakr al Baghdadi al Hussaini al Qurayshi(although it is not confirmed he is from Quryashi descent by outside sources).
In Islam the general ruling is that the killing of Innocent non-combatants is not allowed. One of the evidences used by the Ulema'(Scholars of Islam) is from the Qur'an, in Surah Maaidah(Surah number 5), Verse 5, where Allah(swt) says:
"whoever kills a soul unless for a soul or for corruption [done] in the land – it is as if he had slain mankind entirely. And whoever saves one – it is as if he had saved mankind entirely. " - Sahih International Translation(Most Popular English translation source of the Qur'an).
So this is the general ruling in Islam regarding killing innocent people regardless of whether they are Muslim or a Kafir(non-muslim).
However, in recent times some( a very small minority) scholars have differed regarding this general ruling on whether this applies to the current specific scenario the muslim ummah is facing today.
I am not going to go too far into depth of the Islamic Sciences in explaining this ruling such as Usul ul Fiqh etc, as they are extremely complicated and require years of study to master. Usul ul fiqh is a science which every scholar who passes rulings must have studied, know, understand and have an ijaazah in.
I am now going to shed some light to those who do not have as much insight on why some scholars have given a specific ruling against the general ruling which I have explained above that killing innocent non-combantants is Haraam(not permissable) in Islam. This is a touchy subject and I disagree with this opinion, so as I explain please don't think I support this, it is just to explain so others can really understand, and I will refute this opinion in my final paragraph at the end on why we should also reject this opinion(I am a peaceful Moderate muslim).
We must understand Islam is moderate and Allah(swt) does not burden any soul with anything it cannot bear as he says in Surah Baqarah, verse 286. The general ruling for eating pork and drinking alcohol is that it is haraam for a muslim. However, if the muslim is in a situation whereby there is no water at all, there is no other drink, and he/she is extremely thirsty, the ruling in this specific case is that it halal(permissable). They can drink alcohol enough to just remove their thirst so they will not die. Similarly, if there is no food around except pork and the muslim would die of hunger if he did not eat the pork, then it is permissable for him to eat pork.
Similarly, in recent times, after the US invasion, intervention and wars on the muslim world, Afghanistan, Iraq etc. and their intervention in the muslim world in order to destabilise and maintain their petro-dollar system, there have been a lot of killing of innocent muslim civillians non-stop at the hands of america and it's allies. Therefore, scholars of the muslim world who are located in these areas who are experiencing first hand what is occuring, have explained that this is a crusade by the americans and it's allies, and it is a war between the muslims and them. The killing of innocent muslim civillians has meant that some scholars who have studied usul ul fiqh, have given fatawah(rulings) that the general ruling regarding the killing of innocent non-combatants is abrogated by the verse in the qur'an in Surah Baqarah(Surah number 2) verse 194:
"So whoever has assaulted you, then assault him in the same way that he has assaulted you. And fear Allah and know that Allah is with those who fear Him." - Sahih International.
So you see this is the evidence that some of the scholars use to pass rulings making it permissable for these kind of atrocious attacks on innocent non-combatants. It is a specific ruling given the situation that the muslim world faces which means some scholars have given the ruling that the general ruling is abrogated in this situation. There are some other evidences and ijtihad(Islamic Legal reasoning) that they use but this is basically how they come to the ruling. I am not going to name the small minority of scholars who have given this ruling as it is for your own safety I don't want you to search them up and read more from there as I want you to avoid these individual scholars who hold these extremist idealogies.
Now, I will explain why these fatawah(rulings) are invalid and no one living in the west should act upon these extremist rulings, rather they should be disregarded.
Firstly, it is that we muslims who live in the west have signed an agreement with the non-muslim governments to live in their lands peacefully, abiding by their laws in exchange for being able to live, work, having access to food and shelter and other baisc human needs and being able to practice Islam freely without being oppressed aswell as having a police force for our security/safety. If you have a passport then that means you are in this contract. It is haraam(not permissable) in Islam to break your contracts. Therefore, to break this contract will mean you are incurring a great sin. The evidence given by the scholars for this is in Surah Al-Ma’idah(surah number 5) verse number 1:
"O you who believe, fulfill all contracts."
Another evidence used is Surah An-Nahl (surah number 16) verse number 91:
Fulfill the covenant of Allah when you have taken it, and do not break oaths after their confirmation while you have made Allah a witness over you. Verily, Allah knows what you do.
Secondly, the other refutation point is that we are suppossed to be taking our religion regarding matters of Fiqh(rulings) from the scholars in our area/country. The explanation is that they are the ones who understand the entire situation better because they live here and understand how the west works so they are better qualified to use a principle called 'urf in usul ul fiqh to make more correct rulings. This is why during the time of the Classical Islamic Scholars, when a Man was visiting the Maghreb(Morroco etc) where they followed mostly the fiqhi rulings of Imam Malik(rh), if he were to ask a scholar from there regarding a matter of fiqh, this scholar would tell the man to ask the scholar of his own land of his own country and get his fiqhi rulings from there. Because there may be differences in some of the fiqh(rulings) so as not to confuse the layman. This is why these extremely minor weak extremist opinions held by a handful of scholars who live in a land extremely far away from the west should not be acted upon and rather should be disregarded. The scholars of the west have spoken and they have all said it is haraam.
Hopefully, this sheds some light on this issue to everyone insha Allah.