In 2006, al Qaeda in Iraq -- under the ruthless leadership of Abu Musab al-Zarqawi -- embarked on seemingly arbitrary and brutal treatment of civilians as it tried to ignite a sectarian war against the majority Shia community.

It came close to succeeding, especially after the bombing of the Al-Askariya Mosque, an important Shia shrine in Samarra, which sparked retaliatory attacks.

But the killing of al-Zarqawi by American forces, the vicious treatment of civilians and the emergence of the Sahwa (Awakening) Fronts under moderate Sunni tribal leaders nearly destroyed the group.

Nearly, but not quite.

When U.S. forces left Iraq, they took much of their intelligence-gathering expertise with them.

Iraqi officials began to speak of a "third generation" of al Qaeda in Iraq.

Two years ago, a former spokesman for the U.S. military in Iraq, Maj. Gen. Jeffrey Buchanan, warned that "if the Iraqi security forces are not able to put pressure on them, they could regenerate."

The capability of those Iraqi forces was fatally compromised by a lack of professional soldiers, the division of military units along sectarian lines and a lack of the equipment needed for fighting an insurgency, such as attack helicopters and reconnaissance capabilities.

The new al Qaeda was rebranded in 2006 as the Islamic State in Iraq (ISI). It would add "and Syria" to its name later.

The group exploited a growing perception among many Sunnis that they were being persecuted by the Shia-dominated government led by Prime Minister Nuri al-Maliki, starved of resources and excluded from a share of power.

The arrest of senior Sunni political figures and heavy-handed suppression of Sunni dissent were the best recruiting sergeants ISI could have. And it helped the new leader re-establish the group's influence.

Who is its master of terror?

Abu Bakr al Baghdadi graduated to the top job in 2010 -- at the age of 39 -- after Abu Omar al Baghdadi was killed in a joint U.S.-Iraqi operation.

Al Baghdadi's group was in a pitiful state. But with U.S. forces and intelligence on the way out, he launched a revival.

Very little is known about Abu Bakr al Baghdadi, but a biography posted on jihadist websites last year said he held a Ph.D. in Islamic studies from a university in the capital.

Photos: Iraqi civilians flee Mosul 15 photos

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – Iraqi civilians from Mosul escape to a refugee camp near Erbil, Iraq, on Thursday, June 12. More than 500,000 people fled in fear after extremist militants overran Mosul, Iraq's second-largest city, on June 10, the International Organization for Migration said.

Hide Caption

1 of 15

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – Iraqi refugees pass an area in Erbil on June 12.

Hide Caption

2 of 15

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – Young refugees sleep in a tent at a temporary camp in Aski Kalak, Iraq, on June 12.

Hide Caption

3 of 15

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – A girl from Mosul stands outside her family's tent at a refugee camp near Erbil on Wednesday, June 11.

Iraqi civilians flee Mosul – People believed to be refugees flee Mosul on June 10.

Hide Caption

11 of 15

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – Iraqi families are given water as they gather at a Kurdish checkpoint on June 10.

Hide Caption

12 of 15

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – The rush from Mosul led to bottlenecks at checkpoints as people tried to reach safety in Erbil, about 90 kilometers (56 miles) to the east.

Hide Caption

13 of 15

Photos: Iraqi civilians flee Mosul15 photos

Iraqi civilians flee Mosul – Many people are fleeing on foot. Mosul's four main hospitals are inaccessible because of fighting, and some mosques have been converted to act as clinics, the International Organization for Migration said.

Just Watched

War games or war?

He formed his own militant group in the Samarra and Diyala areas, where his family was from, before joining al Qaeda in Iraq.

Al Baghdadi even served four years in a U.S. prison camp for insurgents, at Bucca in southern Iraq -- a time in which he almost certainly developed a network of contacts and honed his ideology.

He was released in 2009 and went to work.

What is ISIS trying to accomplish?

It wants to establish an Islamic caliphate, or state, stretching across the region.

ISIS has begun imposing Sharia law in the towns it controls. Boys and girls must be separated at school; women must wear the niqab or full veil in public. Sharia courts often dispense brutal justice, music is banned and the fast is enforced during Ramadan.

Sharia law covers both religious and non-religious aspects of life.

Where does the group's money come from?

In the beginning, al Baghdadi focused on secrecy -- with loosely connected cells making it more difficult to hunt down the leadership -- and on money.

Extortion, such as demanding money from truck drivers and threatening to blow up businesses, was one revenue stream; robbing banks and gold shops was another.

It seemed the group had become little more than gangsters, but the income would help finance a growing stream of suicide attacks and assassinations that would poison the political atmosphere.

It would also aid the recruitment of Sunni tribal fighters and finance spectacular prison raids that liberated hundreds of fighters, as well as attacks on police patrols and the assassination of officials.

Now, al Baghdadi has a new strategy for generating resources: large-scale attacks aimed at capturing and holding territory.

Ayham Kamel of the Eurasia Group, a U.S.-based consultancy, says that in the latest iteration of this strategy, ISIS will "use cash reserves from Mosul's banks, military equipment from seized military and police bases and the release of 2,500 fighters from local jails to bolster its military and financial capability."

When it captured Falluja, west of Baghdad, in January, it worked with local tribal leaders rather than raise its black flag over the city.

One of the group's ideologues, Abu Mohammed al-Adnani, even admitted: "As for our mistakes, we do not deny them. Rather, we will continue to make mistakes as long as we are humans. God forbid that we commit mistakes deliberately."

How is it drawing support?

ISIS is, in essence, trying to capture and channel the resentment of the Sunni street. And in both Syria and Iraq, it is trying to win favor through dawa -- organizing social welfare programs and even recreational activities for children, distributing food and fuel to the needy, and setting up clinics.

Again, having the money matters. The price it demands is enforcement of the strict Sharia code.

How does Syria fit into the picture?

A senior U.S. counterterrorism official told CNN this week that ISIS looks at Syria and Iraq as "one interchangeable battlefield and its ability to shift resources and personnel across the border has measurably strengthened its position in both theaters."

The explosion of violence in Syria was a gift to al Baghdadi.

Syrian President Bashar al-Assad lost control over large parts of the North and the long border with Iraq.

The group, still known as ISI at the time, could build a rear base where it could recruit foreign fighters, organize and escape from any Iraqi army operations.

Al Baghdadi may have sent operatives across the border as early as the autumn of 2011, and the group later changed its name -- adding "al Sham" for Syria.

It moved swiftly to take control of the Syrian province of Raqqa, aided by the al-Assad regime's focus on Homs and Aleppo.

What is its relationship with other al Qaeda groups?

As it has grown in strength, the group's vision of a caliphate under its control has expanded.

Its ambition extended to declaring early in 2013 that it was absorbing another militant group in Syria, the al-Nusra Front. According to some accounts, al Baghdadi had been instrumental in creating the group; now he wanted its obedience.

The declaration -- and al-Nusra's rejection of it -- set off a rare public clash between two groups that both saw themselves as part of al Qaeda.

From his hideout somewhere in Afghanistan or Pakistan, al Qaeda leader Ayman al-Zawahiri at first tried to mediate between the two, and then disowned ISIS when it refused to concentrate on Iraq.

Rather than seek reconciliation, ISIS has hit back. Earlier this year, the group's spokesman, Abu Mohammed al-Adnani, told al-Zawahiri in a recording: "Sheikh Osama (bin Laden) gathered all the mujahideen with one word, but you divided them and tore them apart."

"You make the mujahideen sad, and make the enemy of the mujahideen gloat because you support the traitor, and you make the heart bleed," he said -- referring to the leader of the al-Nusra Front, Abu Mohammed al-Jolani.

It was another sign of the extraordinary confidence of the ISIS leadership.

Despite the rift, ISIS' success against what are seen by militant Sunnis as loathsome Shia regimes in Syria and Iraq has attracted thousands of foreign fighters to its ranks, enabling it to continue battling al-Nusra in Syria while preparing for its big offensive in Iraq.

Just Watched

ISIS attacks force Iraqi citizens to flee

For Western counterterrorism agencies, the combination of fanaticism and disciplined organization is the nightmare scenario. ISIS has plenty of both.

While the world was shocked by its sudden capture of the city of Falluja, ISIS was still focused on a bigger prize: Mosul and the province of Nineveh. Operations in Falluja and elsewhere in the western province of Anbar were meant to (and did) draw Iraqi forces away from the north.

It has developed an ability to conduct operations -- from suicide bombings and attacks on the security forces to wresting control of towns -- in several regions at once, keeping the demoralized Iraqi army off balance.

And battle experience has created a resilient force capable of ever more sophisticated attacks.

In raids on Samarra, for example, its fighters used bulldozers to remove barriers that had been in place since the U.S. occupation.

Some analysts expect critical parts of the Iraqi oil infrastructure around Mosul to be among its future targets.

Where does its weakness lie?

ISIS runs the risk that its rapid expansion -- and threat to the Iraqi state -- will overstretch the group.

In northern Syria, it has retreated from some towns it held after clashes with al-Nusra and other groups.

Al-Nusra is making common cause with other groups in an anti-ISIS front.

And by taking Mosul, which Iraq's Kurds see as in their sphere of interest, ISIS may invite greater cooperation between the Iraqi army and experienced Kurdish fighters.

A U.S. counterterrorism official told CNN that ISIS "still has significant weaknesses. It has shown little ability to govern effectively, is generally unpopular, and has no sway outside the Sunni community in either Iraq or Syria."

To many analysts, that smacks of complacency.

How significant is its threat?

The weakness of the governments ISIS is confronting -- and the hatred for those governments among Sunnis -- means that a few dozen truckloads of fighters can seize towns and cities, overcoming forces many times larger by their sheer ferocity and battle experience.

In the words of the Soufan Group, a political risk consultancy, "ISIS has become indisputably the most effective and ruthless terrorist organization in the world."

"It now challenges the authority of two of the largest states in the Middle East, and has attracted significant numbers of fighters, not just from Iraq and Syria, but also from Saudi Arabia and other Arab states including Jordan."

There is no doubting the group's confidence and ambition.

ISIS spokesman al-Adnani took to Twitter Wednesday to declare, "The battle is not yet raging it, but it will rage in Baghdad and Karbala. Put on your belts and get ready," according to a translation by the SITE Intelligence Group.

Al-Adnani openly mocked al-Maliki as an underwear salesman who had lost Iraq for the Shia.

"You lost a historic opportunity for your people to control Iraq," he said, "and the Shi'ites will always curse you for as long as they live."