deadly mix of false allies, crude video Deadly night ... The US Consulate was engulfed in flames in Benghazi late on September 11, 2012. Four Americans, including the amassador, died. Benghazi, Libya: A boyish-looking US diplomat was meeting for the first time with the Islamist leaders of eastern Libya's most formidable militias. It was September 9, 2012. Gathered on folding chairs in a banquet hall by the Mediterranean, the Libyans warned of rising threats against Americans from extremists in Benghazi. One militia leader, with a long beard and mismatched military fatigues, mentioned time in exile in Afghanistan. Libyan National Transitional Council chairman Mustafa Abdel Jalil, right, after presenting his credentials during a meeting in Tripoli. "Since Benghazi isn't safe, it is better for you to leave now," Mohammed al-Gharabi, leader of the Rafallah al-Sehati Brigade, recalled telling the Americans. I specifically told the Americans myself that we hoped that they would leave Benghazi as soon as possible. Yet the militiamen also gushed about their gratitude for President Barack Obama's support in their uprising against Muammar Gaddafi. They emphasised that they wanted to build a partnership with the United States, especially in the form of more investment. The diplomat, David McFarland, a former congressional aide who had never before met with a Libyan militia leader, left feeling agitated, according to colleagues. But the meeting did not shake his faith in the prospects for deeper involvement in Libya. Two days later, he summarised the meeting in a cable to Washington, describing a mixed message from the militia leaders. Then US Secretary of State Hillary Clinton looks on as US President Barack Obama hugs a State Department employee on September 12, 2012, a day after the killing of US Ambassador to Libya Christopher Stevens and three staff members. Despite "growing problems with security," he wrote, the fighters wanted the United States to become more engaged "by 'pressuring' American businesses to invest in Benghazi." The cable, dated September 11, 2012, was sent over the name of McFarland's boss, Ambassador J. Christopher Stevens. Later that day, Stevens was dead, killed with three other Americans in Benghazi in the most significant attack on US property in 11 years, since September 11, 2001. The cable was a last token of months of American misunderstandings and misperceptions about Libya and especially Benghazi, many fostered by shadows of the earlier September 11 attack. The United States waded deeply into post-Gaddafi Libya, hoping to build a beachhead against extremists, especially al-Qaeda. It believed it could draw a bright line between friends and enemies in Libya. But it ultimately lost its ambassador in an attack that involved both avowed opponents of the West and fighters belonging to militias that the Americans had taken for allies. Months of investigation by The New York Times, centred on extensive interviews with Libyans in Benghazi who had direct knowledge of the attack there and its context, turned up no evidence that al-Qaeda or other international terrorist groups had any role in the assault. The attack was led, instead, by fighters who had benefited directly from NATO's extensive air power and logistics support during the uprising against Gaddafi. And contrary to claims by some members of Congress, it was fueled in large part by anger at an American-made video denigrating Islam. A fuller accounting of the attacks suggests lessons for the United States that go well beyond Libya. It shows the risks of expecting US aid in a time of desperation to buy durable loyalty, and the difficulty of discerning friends from allies of convenience in a culture shaped by decades of anti-Western sentiment. The attack also suggests that, as the threats from local militants around the region have multiplied, an intensive focus on combating al-Qaeda may distract from safeguarding US interests. In this case, a central figure in the attack was an eccentric, malcontent militia leader, Ahmed Abu Khattala, according to numerous Libyans present at the time. US officials briefed on the criminal investigation into the killings call him a prime suspect. Abu Khattala declared openly and often that he placed the United States not far behind Gaddafi on his list of infidel enemies. But he had no known affiliations with terrorist groups, and he had escaped scrutiny from the 20-person CIA station in Benghazi that was set up to monitor the local situation. Abu Khattala, who denies participating in the attack, was firmly embedded in the network of Benghazi militias before and afterwards. Many other Islamist leaders consider him an erratic extremist. But he was never more than a step removed from the most influential commanders who dominated Benghazi and who befriended the Americans. They were his neighbours, his fellow inmates and his comrades on the front lines in the fight against Gaddafi. Question of responsibility Fifteen months after Stevens' death, the question of responsibility remains a searing issue in Washington, framed by two contradictory story lines. One has it that the video, which was posted on YouTube, inspired spontaneous street protests that got out of hand. This version, based on early intelligence reports, was initially offered publicly by Susan Rice, who is now Obama's national security adviser. The other, favoured by Republicans, holds that Stevens died in a carefully planned assault by al-Qaeda to mark the anniversary of its strike on the United States 11 years before. Republicans have accused the Obama administration of covering up evidence of al-Qaeda's role to avoid undermining the president's claim that the group has been decimated. The investigation by The Times shows that the reality in Benghazi was different, and murkier, than either of those story lines suggests. Benghazi was not infiltrated by al-Qaeda, but nonetheless contained grave local threats to US interests. The attack does not appear to have been meticulously planned, but neither was it spontaneous or without warning signs. Abu Khattala had become well known in Benghazi for his role in the killing of a rebel general, and then for declaring that his fellow Islamists were insufficiently committed to theocracy. He made no secret of his readiness to use violence against Western interests. One of his allies, the leader of Benghazi's most overtly anti-Western militia, Ansar al-Shariah, boasted a few months before the attack that his fighters could "flatten" the US Mission. The violence, though, also had spontaneous elements. Anger at the video motivated the initial attack. Dozens of others joined in, some of them provoked by the video and others responding to fast-spreading false rumours that guards inside the US compound had shot Libyan protesters. Looters and arsonists, without any sign of a plan, were the ones who ravaged the compound after the initial attack, according to more than a dozen Libyan witnesses as well as many US officials who have viewed the footage from security cameras. The Benghazi-based CIA team had briefed McFarland and Stevens as recently as the day before the attack. But the US intelligence efforts in Libya concentrated on the agendas of the biggest militia leaders and the handful of Libyans with suspected ties to al-Qaeda, several officials who received the briefings said. Like virtually all briefings over that period, the one that day made no mention of Abu Khattala, Ansar al-Shariah or the video ridiculing Islam, even though Egyptian satellite television networks popular in Benghazi were spewing outrage against it. Members of the local militia groups the Americans called on for help proved unreliable, even hostile. The fixation on al-Qaeda may have distracted experts from more imminent threats. Those now look like intelligence failures. More broadly, Stevens, like his bosses in Washington, believed the United States could turn a critical mass of the fighters it helped oust Gaddafi into reliable friends. He died trying. Back in Washington After the attack, Obama vowed retribution. "We will not waver in our commitment to see that justice is done for this terrible act," he said in a televised address from Washington on the morning of September 12. And make no mistake, justice will be done. But much of the debate about Benghazi in Washington has revolved around statements made four days later in television interviews by Ms Rice, who was then ambassador to the United Nations. "What happened in Benghazi was in fact initially a spontaneous reaction to what had just transpired hours before in Cairo," she said on NBC's Meet the Press, "almost a copycat of the demonstrations against our facility in Cairo, prompted by the video." Republicans, pouncing on the misstatement, have argued that the Obama administration was trying to cover up al-Qaeda's role. "It was very clear to the individuals on the ground that this was an al-Qaeda-led event," Mike Rogers, the Republican chairman of the House Intelligence Committee, said last month on Fox News. But the Republican arguments appear to conflate purely local extremist groups like Ansar al-Shariah with al-Qaeda's international terrorist network. The only intelligence connecting al-Qaeda to the attack was an intercepted phone call that night from a participant in the first wave of the attack to a friend in another African country who had ties to members of al-Qaeda, according to several officials briefed on the call. But when the friend heard the attacker's boasts, he sounded astonished, the officials said, suggesting he had no prior knowledge of the assault. Al-Qaeda was having its own problems penetrating the Libyan chaos. Three weeks after the attack, on October 3, 2012, leaders of the group's regional affiliate, al-Qaeda in the Islamic Maghreb, sent a letter to a lieutenant about efforts to crack the new territory. The leaders said they had sent four teams to try to establish footholds in Libya. But of the four, only two in the southern Sahara "were able to enter Libyan territory and lay the first practical bricks there," the letter said. The letter, left behind when the group's leaders fled French troops in Mali, was later obtained and released by The Associated Press. In the days after the Benghazi attack, meanwhile, Abu Khattala was still at work on construction sites and moving at ease around the city, even mocking the US political debate about the ambassador's death. "It is always the same two teams, but all that changes is the ball," he said in an interview. They are just laughing at their own people. He suggested that the video insulting the Prophet Mohammad might well have justified the killing of four Americans. "From a religious point of view, it is hard to say whether it is good or bad," he said. By northern summer, US investigators had interviewed hundreds of witnesses and formally asked the Libyan government to arrest Abu Khattala, along with about a dozen others wanted for questioning. The US military also prepared a plan to capture him on its own, officials said. But the administration held back, fearing that unilateral US military action could set off a backlash that would undermine the fragile Libyan government. Al-Gharabi said Libya's prime minister, under pressure from the Americans, had asked a Benghazi army commander for help apprehending Abu Khattala. Al-Gharabi quoted the commander as replying, "You will be lucky if he does not apprehend you."