While the origin of flags is unclear, they did have their use on the battlefield as a way to distinguish different groups and possibly intimidate. If an army had a particular reputation, a flag could signal their presence. Given their use on the battlefield, it makes sense that modern day jihadist organizations, which see themselves at war with much of the world, would use them for similar purposes. In videos of ISIS taking Mosul, the Black Flag can be seen held high.
According to the Combating Terrorism Center the Black Flag, also called the Black Standard, or al-raya, has its roots in the flag that the Prophet Muhammad, as well many of his companions, carried into battle. Usage of the flag waned until, as the leader of the Abbasid Revolution, Abu Muslim used it during the revolt against the Umayyad Caliphate. With the objective of establishing a strict orthodox Islamic regime, the Black Flag has been used as a symbol of jihad.
While the Black Flag is never mentioned in the Quran, some groups claim it has religious significance. They cite the Hadith as evidence. Some books of the Hadith claim that a group coming from Khurasan (an historical region in modern day Central Asia and the Middle East) flying the Black Flag before the end of the world. According to the Hadith, the group carrying the flag will be a legitimate group that Muslims are obliged to support and join. In The Black Flag Myth: An Analysis from Hadith Studies, Mustazah Bahari and Muhammad Haniff Hassan review the referenced Hadith. In their conclusion, the references to the Black Flag in the Hadith cannot be verified and many Islamic scholars do not take them as authentic. The Hadith is also vague in the design of the flag, simply stating that it is a Black Flag.
The writing on the flag is the shahada, an Islamic decree of faith. Meaning "the testimony", the shahada is one of the Five Pillars of Islam, which are the mandatory acts of a believer. Reciting the shahada is required to become Muslim and there are two shahadas, reflecting two important aspects of Islam: there is no god but God and Muhammad is the messenger of God. Given the religious nature of jihad, one can see the importance of putting it on the flag as both an expression of the belief of those waging jihad and a notice to those on which they are waging jihad. The importance of accepting that there is only one God, the Islamic God, can be seen in the name of the jihadist group Jama'at al-Tawhid wal-Jihad which translates to Organization of Monotheism and Jihad.
There is no single jihadist flag and there can be little consistency within a single group. al-Qaeda in Iraq, which would eventually become ISIS, used at least five flags, and at least three flags under it's previous name Jama'at al-Tawhid wal-Jihad. The flag of ISIS, however, has been consistent and has been a powerful tool in branding and recruitment. The flag of ISIS contains the shahada as well as the Seal of Muhammad. The seal reads Muhammad, messenger of God.
Given the success of the ISIS flag in branding, several countries have made it illegal to display the ISIS flag in non-educational contexts. In 2014, the Netherlands banned the flag prior to a pro-Palestine march. Similarly, in 2014, Germany banned activities that support ISIS, including displaying the flag and any recruitment attempts. In the United Kingdom, the Terrorism Act 2000 makes it illegal to display symbols that support a terrorist group however the police may not necessarily enforce it.