Iraqi Army Brig. Gen. Falah Hassan Kanbar, the top Iraqi security official for northwest Baghdad, stands outside the U.S. Army's Forward Operating Base Justice in north Baghdad, Iraq on Friday, Aug. 10, 2007. Earlier this week Kanbar survived an assassination attempt by suspected Mahdi Army militiamen. (AP Photo/Petr David Josek)

BAGHDAD -- A Muslim imam dropped his cloak to the sidewalk. It was a signal for the gunmen to move.

They surrounded the top Iraqi security official in a north Baghdad district. Iraqi military vehicles -- commandeered by other Shiite militiamen -- screeched into a cordon, blocking his exit. A gun was put to his head.

Brig. Gen. Falah Hassan Kanbar, a fellow Shiite, managed to escape when his bodyguards pulled him into a vehicle that sped down an alley.

Details of the Aug. 5 ambush emerged this week in interviews with Kanbar, U.S. military and intelligence officials. Suspicions over the source of the brazen assault pointed in just one direction: the powerful Shiite armed faction known as the Mahdi Army and its increasingly unpredictable trajectory.

The vast Mahdi network -- ranging from hard-core fighting units to community aid groups -- is emerging as perhaps the biggest wild card as Iraq's U.S.-backed government stumbles and the Pentagon struggles to build a credible Iraqi security force to allow an eventual U.S. withdrawal.

Just a few months ago, the Mahdi Army and its leader, firebrand cleric Muqtada al-Sadr, were seen as reluctant -- but critical -- partners with Iraq's leadership. Al-Sadr agreed to government appeals to lessen his anti-American fervor and not directly challenge the waves of U.S. soldiers trying to regain control of Baghdad and surrounding areas.

But now, the once-cohesive ranks of the Mahdi Army are splintering into rival factions with widely varying priorities.

Some breakaway guerrillas are accused by Washington of strengthening ties with Iranian patrons supplying parts for powerful roadside bombs.

Other Mahdi loyalists are seeking to expand their footholds in the Iraqi military and police, frustrating U.S. attempts to bring more Sunni Muslims into the forces as part of national reconciliation goals.

The Mahdi Army, meanwhile, appears to be going through its own leadership crisis. Al-Sadr has been unable to rein in the renegade Mahdi factions. On Friday, a U.S. military commander said al-Sadr had returned to Iran. Al-Sadr's top aides called the claim baseless.

For the U.S. military, the gun-wielding attack on the Iraqi brigadier general in Kazimiyah highlights just how far the Mahdi bosses are willing to go against anyone they cannot control.

"[He] is the cleanest guy you can find in Kazimiyah, and he works with us. That's why they want him dead," said Capt. Nick Kron, 28, a Richmond, Va., native with the Army's 1st Infantry Division.