Short Answer
Modern terrorism as we understand it today originated in the late 1960s and has gradually spread across different movements as a tactic, including Islamic terrorism movements, since then.
The rise of this tactic in the Middle East more or less coincided with its appearance in places like Ireland, Continental Europe and Sri Lanka by non-Islamic forces and with the rise of asymmetric warfare tactics in the Vietnam War.
This tactic arose for military reasons, because alternative means of conventional warfare became less viable.
These tactics were used at all, in the Middle East, initially, as emerging fundamentalist Islamic movements fueled by rising literacy the removed the intermediation of formally trained religious leaders interpreting religious texts. This grass roots fundamentalist Islamic movement (in the sense of getting back to fundamentals of religious texts with less interpretation) arose as what was seen as a widely unifying less corrupt means to counterbalance the twin opponents of Israel on one hand, and secular leaning totalitarian communist and absolute monarchs that were perceived as oppressive, on the other. The absolutist regimes grew indifferent to the masses whose fundamental economic productivity lagged behind rising wealth from oil facilitated by OPEC at first, while those with access to oil wealth prospered.
The regimes against which Islamic terrorism was directed came to power in a manner that arose from missteps in the process of breaking up the Ottoman Empire and flawed process of facilitating Zionism without unduly disrupting pre-existing residents in a massively disruptive way that led to multiple rounds of war.
Long Answer
There is more than one meaningful answer to your question considered at different levels of remoteness and with different kinds of causation. Obviously, this answer could stretch to many books in length. This answer attempts to hit the most pivotal high points and to demonstrate what was happening by example where possible.
The Long War Of Ottoman Succession
To some extent, almost all of the conflicts in the Middle East are partially traceable to the poor job that was done partitioning the Ottoman Empire, which was dismantled by the winning "Great Powers" following World War I. As Wikipedia summarizes at the link in this paragraph (references omitted):
The partitioning of the Ottoman Empire led to the rise in the Middle
East of Western powers such as Britain and France and brought the
creation of the modern Arab world and the Republic of Turkey.
Resistance to the influence of these powers came from the Turkish
national movement but did not become widespread in the post-Ottoman
states until after World War II.
The League of Nations mandate granted French Mandate for Syria and the
Lebanon and British Mandate for Mesopotamia (later Iraq) and British
Mandate for Palestine, later divided into Mandatory Palestine and
Emirate of Transjordan (1921-1946). The Ottoman Empire's possessions
in the Arabian Peninsula became the Kingdom of Hejaz, which was
annexed by the Sultanate of Nejd (today Saudi Arabia), and the
Mutawakkilite Kingdom of Yemen. The Empire's possessions on the
western shores of the Persian Gulf were variously annexed by Saudi
Arabia (Alahsa and Qatif), or remained British protectorates (Kuwait,
Bahrain, and Qatar) and became the Arab States of the Persian Gulf.
After the Ottoman government collapsed completely it signed the Treaty
of Sèvres in 1920. However, the Turkish War of Independence forced the
European powers to return to the negotiating table before the treaty
could be ratified. The Europeans and the Grand National Assembly of
Turkey signed and ratified the new Treaty of Lausanne in 1923,
superseding the Treaty of Sèvres and solidifying most of the
territorial issues. One unresolved issue, the dispute between the
Kingdom of Iraq and the Republic of Turkey over the former province of
Mosul was later negotiated under the League of Nations in 1926. The
British and French partitioned the eastern part of the Middle East,
also called Greater Syria, between them in the Sykes–Picot Agreement.
Other secret agreements were concluded with Italy and Russia. The
Balfour Declaration encouraged the international Zionist movement to
push for a Jewish homeland in the Palestine region. While a part of
the Triple Entente, Russia also had wartime agreements preventing it
from participating in the partitioning of the Ottoman Empire after the
Russian Revolution. The Treaty of Sèvres formally acknowledged the new
League of Nations mandates in the region, the independence of Yemen,
and British sovereignty over Cyprus.
This doesn't tell the full story, however.
The trouble is that the new regimes were despotic. The process frequently put minority factions in positions of power over majorities. The process allowed those in power to be corrupt and ignore the popular will. The process did not accurately draw lines reflecting ethnic human geography in the region splitting ethnic groups between states and creating ethnic minorities that were oppressed.
But, for half a century, this fragile arrangement nonetheless held together more or less, until it was really stressed as colonial powers withdrew their control voluntarily in favor of local despots who had previously been restrained by colonial oversight, starting mostly around 1960. It took only a few years for the legacy regimes to prove unstable and be replaced by more stable, totalitarian arrangements.
The Anti-Israel Movement
Shifting multi-national coalitions of Middle Eastern countries attempted to wipe out Israel, after it gained formal international recognition in the wake of the Holocaust of World War II, in a succession of short wars including an Arab invasion of Israel in 1948, the June 1967 Arab-Israeli War, a failed attempt to recapture the Golan Heights in 1973, and other shots fired in anger which history does not dignify with formal names. Needless to say, they all failed.
Many Middle Eastern countries adopted a formal policy favoring the elimination of the state of Israel, and the Arab League, founded in 1945, had long organized opposition to Israeli treatment of Palestinians on a regional international level.
President Carter the brokered the Camp David Accords in 1978 which secured buy in from Israel's neighbor, Egypt, to not invade or try to wipe out Israel, in exchange for military and civilian economic aid and a desire for a more lasting peace. This resulted in a 1979 peace treaty between Israel and Egypt. The United States used its influence in a similar, but less formal way to disabuse Saudi Arabia (which does not have formal diplomatic relations with Israel) of its desire to eliminate the State of Israel around the same time. More or less, that peace has held since then.
But, the legacy of having almost all of the sovereign states of the region formally declaring Israel to be their enemy deserving destruction or at least woefully opposed due to its treatment of the Palestinians, the cause of the ill treated Palestinians displaced by Zionist migration of Jews to Israel, and a shift towards religious fundamentalism discussed below, all legitimatized those who turned to terrorism as a tactic to use against Israel in this ongoing territorial and religious clash of international proportions.
Terrorist attacks in Israel start to surge in the late 1960s:
The Fall of Western Style Societies In The Middle East
While the partition of the Ottoman Empire set the stage for later terrorism in the modern sense, though in the 1960s and 1970s countries like Afghanistan, Lebanon, Egypt and Iran had moved very far in a Western direction under monarchies or socialist regimes, were relatively free of organized internal violence, and were experiencing expanding economic and expression rights for their citizens, although most regimes were still fundamentally either one party regimes or monarchies.
For example, in 1964, the monarch of Afghanistan instituted a new liberal constitution that was supposed to transition the country from an absolute monarchy to a constitutional monarchy with an elected parliament, a strict regulation of daily life according to fundamentalist readings of Islamic law was relaxed.
A park in Afghanistan in the 1970s
These economies also tended to be somewhat hollow with weak fundamentals propped up with revenues from oil resources for which high prices were maintained by the OPEC oil cartel, formed in 1960, which provide prosperity that could support a liberal lifestyle.
A Conservative Religious Revival
One of the important consequences of this process, however, as described by my Islamic studies professors in college from first hand knowledge and intensive scholarship, was that the rate of literacy among "the masses" dramatically increased. This allowed large swaths of the population that previously had access to Islamic religious writings mediated through religious scholars who embedded those writings in interpretive doctrines that mitigated how they were applied in practice to read them directly, to interpret them without the long religious tradition associated with them in a very literal way, and to become self-appointed religious leaders. This is explained here:
What would become Protestantism was inextricably linked to the advent
of mass literacy, as a growing number of believers were no longer
dependent on the intercession of clerics. With the New Testament
translated for the first time into German and other European
languages, the faithful could directly access the text on their own.
The Muslim world, by comparison, has already experienced a weakening
of the clerics, who, in being co-opted by newly independent states,
fell into disrepute. In Europe, the decline of the clerical class and
mass literacy laid the groundwork for secularization. In the modern
Middle East, these same forces coincided with political Islam’s
ascendancy. The Egyptian Muslim Brotherhood disproportionately drew
its leadership from the professional sectors of medicine, engineering,
and law. The movement, founded in 1928, was decidedly non-clerical
and, in some ways, anti-clerical. In the 1950s, Cairo’s al-Azhar, the
Arab world’s preeminent center of Islamic thought, was co-opted and
politicized by Gamal Abdel Nasser’s regime, the Brotherhood’s chief
antagonist.
The much more literalist Salafis also had little time for the
religious establishment. The premise of Salafism was that centuries of
intricate and technical Islamic scholarship had obscured the power and
purity of Islam, as embodied by the Prophet Muhammad and his
companions. Salafi leaders told their followers that the Quran’s
meaning could be accessed by simply reading it and following the
example of the Prophet. Salafism—and for that matter groups like
al-Qaeda and ISIS—would be inconceivable without the weakening of the
clerics and the democratization of religion interpretation.
Then, existing conservative theological movements such as Salafi Islam (often with support from wealthy elites from Saudi Arabia and from elites in other Arab Muslim monarchies), who had resented and opposed the Westernization of these societies for their corruption and immorality stepped in to lead the emerging grass roots movement.
Of course, the process is far more complex than this thumbnail sketch, and is influenced by a lot of complex internal structure of the relationship between different factions within Islam.
The transition bore strong similarities to the rise of Evangelical Christianity in the United States where independent, not very well educated grass roots revivalist preachers sought to return Christianity to its fundamentals after they were freed of the constraints and clergy dominated filter of religious knowledge to the masses and interpreted Christian religious texts literally based on their own readings of them without regard to later religious traditions in the Second Great Awakening.
The U.S. and the U.K. supported these movements at first, as Wikipedia explains (references omitted from quotation):
During the Cold War following World War II, some NATO governments,
particularly those of the United States and the United Kingdom,
launched covert and overt campaigns to encourage and strengthen
fundamentalist groups in the Middle East and southern Asia. These
groups were seen as a hedge against potential expansion by the Soviet
Union, and as a means to prevent the growth of nationalistic movements
that were not necessarily favorable toward the interests of the
Western nations. By the 1970s, the Islamists had become important
allies in supporting governments, such as Egypt, which were friendly
to U.S. interests. By the late 1970s, however, some fundamentalist
groups had become militaristic leading to threats and changes to
existing regimes. The overthrow of the Shah in Iran and rise of the
Ayatollah Khomeini was one of the most significant signs of this
shift. Subsequently fundamentalist forces in Algeria caused a civil
war, caused a near-civil war in Egypt, and caused the downfall of the
Soviet occupation in Afghanistan. In many cases the military wings of
these groups were supplied with money and arms by the U.S. and U.K.
A more detailed timeline of this involvement can be found in this 2006 article.
Needless to say, the U.S. and U.K. came to regret their support of these movements later on.
The current generation of people carrying out Islamic terrorist attacks in Western countries also carry some common characteristics; they are:
second generation; fairly well integrated at first; period of petty
crime; radicalisation in prison; attack and death – weapons in hand –
in a standoff with the police.
Another characteristic that all western countries have in common is
that radicals are almost all “born-again” Muslims who, after living a
highly secular life – frequenting clubs, drinking alcohol, involvement
in petty crime – suddenly renew their religious observance, either
individually or in the context of a small group. . . .
In almost every case, the processes by which a radical group is formed
are nearly identical. The group’s membership is always the same:
brothers, childhood friends, acquaintances from prison, sometimes from
a training camp. The number of sets of siblings found is also
remarkable.
the radical preachers’ rhetoric could basically be summarised as: “Your
father’s Islam is what the colonisers left behind, the Islam of those who
bow down and obey. Our Islam is the Islam of combatants, of blood, of
resistance.”
Radicals are in fact often orphans . . . or come from dysfunctional
families. They are not necessarily rebelling against their parents
personally, but against what they represent: humiliation, concessions
made to society, and what they view as their religious ignorance.
These men aren't crazy. These men see themselves a bit like Batman, wealthy men using their power and education to secure what they see as justice outside the law, or if less affluent, like the demon hunting brothers of Supernatural, or as medal of honor candidates who are heroes willing to put their lives on the line for the cause.
The cause, in turn, is born of religious revival in response to bad, foreign influenced local regimes, and the methods flow from the futility of trying to achieve their ends with either politics or a conventional military force.
Regime's Response To The Rise Of Islamic Fundamentalism
Different regimes responded to rising fundamentalist Islamic religious sentiment in different ways.
In Afghanistan, a 1973 coup to remove the monarchy was followed by a communist coup in 1978, followed by "imprisoned, tortured or murdered thousands of members of the traditional elite, the religious establishment, and the intelligentsia. The government launched a campaign of violent repression, killing some 10,000 to 27,000 people and imprisoning 14,000 to 20,000 more, mostly at Pul-e-Charkhi prison." The Communist regime led to a Soviet invasion in 1979, and Afghanistan anti-communist forces, some of the more effective of which were Islamic fundamentalist with Saudi Arabian support, were important players in a civil war that continued with only brief interruption until the 2001 arrival of U.S. forces in the wake of the 9-11 attacks. Terrorism was a tactic there against various other factions including the U.S. and its allies into the present.
In Lebanon, a civil war broke out on religious lines in 1975 and continued until 1990.
In Iran, protest movements in 1977 and 1978 gave rise to Iran's Islamic Revolution of 1979. This was followed in short order by the Iran-Iraq War from 1980 to 1988 in which new tactics including suicidal "human wave attacks" by people with explosives indoctrinated to be martyrs, widespread attacks on civilian targets, and the use of chemical weapons, set precedents about acceptable means that were then widely adopted elsewhere in smaller scale terrorist attacks as part of asymmetric warfare.
Iraq tried to prevent terrorism from breaking out not by "joining them" as the Iranian Revolution's regime did, but by imposing a totalitarian regime that muted ethnic and religious tensions somewhat at the cost of forcing people to chafe under its own regime's unpopular restrictions.
In Egypt, Syria, Iraq and Turkey, secularly inclined military forces and one party regimes clamped down on dissent to prevent political movements that they didn't control from emerging and suppressed religious political movements.
Syria became a one party regime in 1963 that was controlled by a comparatively liberal and pro-Western Alawite minority that had been favored during the French League of Nations mandate of Syria. It intervened in a Jordian-Palestinian Civil War in 1970 that gave rise to official Syrian support of the PLO which engaged in anti-Israeli terrorism when it withdrew in 1970.
Tactics used in one conflict spread to others, for example in the bombing of U.S. forces in Beirut in 1983.
Wealthy, often unemployed but religiously educated lesser members of the royal family in Saudi Arabia held spread ultra-conservative Salafi Islamic approaches to Sunni Islam throughout the Middle East as a way to counter corrupt secular communist regimes in the region thus expanding their own worldview as well: "Salafi groups ... began developing an interest in (armed) jihad during the mid-1990s."
Bottom Line
So, while the source of modern Islamic terrorism in the Middle East has somewhat deep political roots, it can really be traced to a religious reaction of the rise of Israel on the one hand, and secular communist Western leaning regimes on the other, starting around the late 1960s and early 1970s and escalating over time since then.
In Europe and the United States, a primarily Middle Eastern Islamic terrorism phenomena spread via immigration to countries that were destinations of immigrants by minorities who favored radical action in a larger movement largely directed a local, Western supported corrupt and oppressive tyrants in their homelands. This started to become more common in the early 2000s, following a brief low point in European based terrorist activity (see the chart below).
The rise in Islamic terrorism in the West (Europe and the U.S.) in the 2000s pretty much boils down to deliberate policy choices made by a couple of international jihadist organizations: the al-Qaeda terrorist organization and the thinly linked subsequent Islamic State organization.
Islamic terrorist tactics spread beyond the Middle East to places like Libya, East Africa, the Sahel zone of Africa, Pakistan, Thailand, Indonesia, and the Philippines, largely following the model of Middle Eastern jihadists.
Caveats And A Larger Global And Historical Context
Terrorism is not and never has been exclusively or primarily Islamic. It is really just one type of asymmetric warfare which has been more common historically than the wars between equally matched forces in international wars that dominate the history books.
But, starting around the late 1960s, asymmetric warfare became the truly dominant means of conflict internationally because technologies like machines guns, tanks and warplanes made conventional warfare between well equipped government forces and ill equipped insurgent forces futile. The total and rapid victory of the U.S. and its allies against Iraq in the Gulf War in Iraq from 1990 to 1991, cemented this widespread belief.
Also, the threat of mutual assured destruction in a nuclear war during the Cold War discouraged international conflicts in which a nuclear power such as Russia, the U.S. or China sided with a party to the conflict.
The antiquity of terrorism is illustrated, for example, by the term assassin, which derives from derives from what we would call today a Shia Islamic terrorist group ca. 1000 CE, with roots in Northern Persia fighting back against both Crusaders and Sunni Islamic oppressor regimes.
Terrorism was a central tool in the conflict between the English and the Irish in Ireland and later once Ireland gained independence, in Northern Ireland. "The Troubles" in Northern Ireland which were heavily marked by terrorist activity started around 1969.
Basque and Northern Italian separatists in Europe turned to terrorism. The first terrorist attack attributed to the Basque ETA was in 1968. The Red Brigades championing Northern Italian autonomy engaged in terrorist attacks starting in the 1970s.
Modern terrorist attacks have continued at a slow and steady rate by various factions of the day in Europe (mostly domestic autonomy movements) since the 1970s and fell off towards the end of the 1990s.
Image via Datagraver.
Terrorist tactics were widespread in Sri Lanka in connection with a 26 year civil war between Tamil forces and the government that continued from the early 1980s through 2009.