For most Americans (and those around the world), the terrorist attacks of September 11, 2001 came as a shock. But for American and international investigators, warning signs of the attack had been brewing for more than a decade. Below, several key seeds that bore fruit on 9/11:

The Soviet-Afghan war laid the table for later conflicts.

In the 1980s, future al-Qaeda leaders including Osama bin Laden, Ayman al-Zawahiri and others joined in Afghanistan’s war against the Soviet Union, an experience that helped radicalize them in the decade that followed.

When the Soviets invaded Afghanistan in December 1979, they were fiercely resisted by Afghan fighters known as mujahideen, who declared a holy war, or “jihad,” against the Soviets, whom they considered infidels. The mujahideen quickly gained support from other parts of the Islamic world, with thousands flocking to Afghanistan and Pakistan to fight in or support the Afghan resistance. Among those supporters: bin Laden and other future leaders of extremist groups. The logistical and tactical lessons—and the relationships formed amongst these Muslim resistance leaders—had lasting consequences.

In the early 1990s, a fundamentalist Islamic group known as the Taliban, comprised primarily of former mujahideen, rose to power in post-war Afghanistan. They took over the country in 1996, establishing a harsh, repressive regime that provided support and protection for bin Laden, who returned to the country with other extremists and soon founded al-Qaeda.

A post-WWI treaty angered bin Laden.

Al-Qaeda was created, in part, to globalize the fight between fundamentalist Islam and the Western world. To that end, its leaders leveraged new communications technologies of the ’90s—satellite cable stations and the world wide web—to spread their jihadist messages to the wider Muslim world and attract converts to their cause.

Al-Qaeda and other extremist groups also looked to avenge what they considered decades of mistreatment of Arab nations at the hands of the West. Bin Laden and others specifically made reference to the Sykes-Picot Treaty of 1916, a secret negotiation during World War I that carved up the Ottoman Empire and created new Arab states in the Middle East. Its intention: to deny these states self-rule and keep them under British and French control, or influence.

WATCH: The full special 9/11: The Final Minutes of Flight 93 online.

Osama bin Laden, leader of the terrorist group al-Qaeda, explaining why he has declared a 'jihad' or holy war against the United States on August 20, 1998 from a cave hideout somewhere in Afghanistan. CNN/Getty Images

“What America is tasting now is something insignificant compared to what we have tasted for scores of years,” said bin Laden in one of his first addresses after 9/11. “The Islamic world has been tasting this humiliation and this degradation for 80 years.” The Sykes-Picot agreement, Peter Bergen wrote in Prospect Magazine, had “the same resonance [for bin Laden] that the 1919 treaty of Versailles did for Hitler. It must be avenged and reversed.”

For bin Laden, a prime example of this “humiliation” was the presence of American and coalition troops in Saudi Arabia (home to some of Islam’s holiest sites) during the 1991 Persian Gulf War against then-Iraqi leader Saddam Hussein. He used it as one of the pretexts for his declaration of jihad against the United States.

As Islamic nations fought among themselves, bin Laden wanted the U.S. out of the fray.

Bin Laden and others were also highly critical of their home countries, whose authoritarian regimes had brutally cracked down on dissenting voices. Their plans for jihad included toppling these regimes, which they considered apostates who had abandoned their Muslim principles.

Bin Laden believed that fighting the “far enemy” of the United States would force the superpower to withdraw from the Middle East entirely, allowing extremists like al-Qaeda to take control from the “near enemies,” including Saudi Arabia, Egypt and other Muslim nations. “War with the United States was not a goal in and of itself, but rather an instrument designed to help his brand of extremist Islam survive and flourish among the believers,” wrote Michael Scott Doran in a 2002 issue of Foreign Affairs. “Americans, in short, have been drawn into somebody else's civil war.”

New York Police Department Bomb Squad inspects the crater caused a terrorist's truck bomb at the World Trade Center on February 26, 1993. Allan Tannenbaum/Getty Images

American intelligence agencies were slow to connect the dots—and realize the threat.

The first jihadist attack on U.S. soil, the February 1993 bombing of the World Trade Center, killed six people and injured more than 1,000. Authorities arrested several Islamic terrorists soon after, but the mastermind, Ramzi Ahmed Yousef, wasn’t apprehended until two years later, when investigators discovered evidence of even more terrorist plots—including a planned assassination attempt on Pope John Paul II and the bombing of American airliners. The plotters also had ties to Omar Abdel Rahman, an Egyptian extremist known as the “Blind Sheik,” who was later convicted of plots to destroy several New York City landmarks.

Throughout the 1990s, bin Laden, Sheikh Mohammad and others funded and set up terrorist-training centers in the Middle East and Africa, as well as cells to train recruits in Western cities like Hamburg, Germany. But it wasn’t until 1996 that the CIA set up a unit, known as “Alec Station,” to track bin Laden. That same year, bin Laden declared a jihad against the United States; the following year, in his first interview with a Western TV journalist (CNN’s Peter Arnett), he articulated al-Qaeda’s plans against America.

It wasn’t until after the bombing of two U.S. embassies in Kenya and Tanzania in August 1998, which killed more than 200 people, that American investigators began to suspect that Yousef and others had ties to Osama bin Laden and al-Qaeda. In fact, Yousef’s uncle was Khalid Sheikh Mohammed, a high-ranking al-Qaeda member, and the mastermind of the 9/11 attacks, plans for which were already underway.

Photos of suspected 9/11 hijackers of American Airlines flight #11, United Airlines flight #93, American Airlines flight #77 and United Airlines flight #175. FBI/Getty Images

The CIA had numerous chances—but blew them.

In the 1990s, law-enforcement agencies had multiple opportunities to stop the plot, but failed—because of a lack of coordinated intelligence-sharing, bureaucratic infighting and a failure to grasp the sheer scope of the threat at hand. “I think the resources the country mustered to prevent al-Qaeda terrorism were not proportionate to the scale of the threat,” said Steve Coll, author of Ghost Wars: The Secret History of the CIA, Afghanistan and Bin Laden. “That was a problem that did cross into the first nine months of the Bush administration but germinated mostly during the Clinton administration.”

Some in the intelligence community didn’t believe that Arab extremists were coordinated enough to work together to plot large-scale attacks, despite having worked together in Afghanistan to force Soviet withdrawal. Even as al-Qaeda’s attacks grew in scope, agencies were reluctant to fully accept that the group diverged from previous terrorists in that they were willing to kill civilians on a large scale.

Even the investigators who could see the outlines of a bigger conspiracy had little support from highest levels, and didn't receive the time, funding and support they needed for full investigations. And when the United States did launch retaliatory attacks on al-Qaeda (including after the bombing of the USS Cole in Yemen in October 2000), they were limited enough in scope that bin Laden and others felt emboldened to move forward with 9/11 plans.

As Coll says, “They got lucky. If the scale of this attack had been prevented—even if the hijackings had been limited to a single one—it would not have changed the course of American history the way September 11 did... That turned out to be their highest military achievement. If it had been prevented, history might have turned in a different way.”