There are several sources of "modern" terrorism in the Middle East and each source feeds off of each other. This is a broad question and I am best familiar with one of the sources, so I'll stick to that. The way I see it, the three main sources are
Terrorism surrounding the Israeli/Palestinian conflict (Like Hezbollah, Palestinian Islamic Jihad, and Hamas in the 80s and 90s). This conflict still rages and over time it has featured several famous terrorist organizations. The Israeli/Palestinian conflict has been a rally cause for political violence in the Middle East for decades.
Various Islamic terrorist groups based in and focused on overthrowing dictators in specific Arab countries (groups like Gamma Islamiyya and Egyptian Islamic Jihad). Unlike Bin Laden these groups didn't target the West as their primary enemy, they were focused on overthrowing what they saw as illegitimate governments run by dictators in the Arab World.
Al Qaeda and the emergence of globally-focused Islamic terrorism (My focus below)
So I will focus on number three because that is the category I know best, but I must inevitably refer to the other two because these other categories fed the movement of Al Qaeda. The Soviet invasion of Afghanistan gave "pan-Islamist" terrorists a cause to rally around, and rally they did. Ideologues such as Osama Bin Laden and Abddulla Azzam set up shop in neighboring Pakistan and hosted an influx of Arabs who came initially to support the cause of helping fellow Muslims in need.
However, Bin Laden had other plans for these "Arab Afghans." He wanted to create a group from which to base his movement that would focus on the "far enemy." Let me pause briefly to identify what I mean by "far enemy" and what "near enemy" would mean. Up until this point (late 80's) and continuing even into the 90's Islamic terrorist groups were largely focused on toppling what is called the "near enemy," or, the dictatorial regimes in specific countries that they saw as illegitimate. Furthermore, the conflict over Palestine continued to spur political violence in Israel. However, they were largely unsuccessful (Palestine never became a fully-legitimate state and Arab strongmen proved resilient and stayed in power) and soon Bin Laden and like-minded individuals sought to re-direct their attention to a new, "far-enemy." This refers primarily the United States but also other western countries who they saw as propping up these dictators in the Arab world and the source of corrupting moral influence.
Ok so, back to the Soviet-Afghan war. As these Arabs responded to the call to help their Muslim brothers in need, Bin Laden sought to create a group from some of them so that could realize his goal of waging war on the United States. He was successful in creating his special group which continued to be ideologically indoctrinated to his view of global terrorism against the West. They spent the remainder of the Afghan Jihad more or less going through basic training and indoctrination.
There is a lot of intervening history, such as the groups move to Sudan and continuing development there, but what is important is that Al Qaeda got its start during the Afghan Jihad and this group that Bin Laden created in Pakistan. Al Qaeda would thus grow to prominence after the September 11th attacks in the U.S. and would see its ranks swell in Iraq and Afghanistan (to a lesser degree) as it fought the Americans who brought the fight to Al Qaeda's home turf. Unfortunately I am now breaking the 20 year rule for this sub so I will leave it there although there is still much to say.
As a recap, Al Qaeda got its start during the late 80's as Bin Laden sought to re-direct some of those who responded to the call to help their fellow Muslims in Afghanistan against the Soviets. This group of individuals would go on to form Al-Qaeda under the banner of waging war on the West and other outside powers who they saw as corrupting the Muslim World.
Sources:
The Looming Tower: Al-Qaeda and the Road to 9/11 by Lawrence Wright
Jihad in Saudi Arabia: Violence and Pan-Islamism since 1979 by Thomas Hegghammer