Years of U.S.-Saudi Teamwork Led to Airline Plot's Failure WASHINGTON - In the video, Yemeni militants can be seen forcing their prisoner to his knees in the bright sunlight. The gunmen read out a death sentence declaring the man to be a Saudi spy who hoped to infiltrate Al Qaeda, and then, as the screen goes blank, a rifle shot rings out, followed by cries of "God is great!" That gruesome clip was released by Al Qaeda's Yemeni affiliate in March, two months before the revelation this week that American and Saudi intelligence agencies had infiltrated Al Qaeda in Yemen and foiled an effort to smuggle a bomb onto a United States-bound jetliner. But it offers a glimpse of the clandestine battle going on in the remote mountains and deserts of Yemen, where Saudi Arabia and the United States have worked closely together against a militant network that remains determined to strike American targets. That collaboration appears to have intensified over the past two years, despite a long history of mistrust rooted in the role of Saudi hijackers in the attacks of Sept. The relationship was tested again last year when Saudi leaders responded furiously to American endorsement of the revolt that ousted a Saudi ally, President Hosni Mubarak of Egypt. American diplomats were surprised and angered in turn soon afterward when Saudi Arabia sent troops to help put down unrest in neighboring Bahrain. But when it comes to counterterrorism, the Saudis have been crucial partners, not only for the United States but also for an array of other Western powers. The crucial testing ground for that partnership is now Yemen, where the local affiliate of Al Qaeda continues to plan attacks against Western targets even after the killing of its chief ideologue, Anwar al-Awlaki, an American-born cleric, in a drone strike in the Yemeni desert last September. "The Saudis have a special position in Yemen - they can do what the Americans cannot do," said Mustafa Alani, a security analyst at the Gulf Research Center in Dubai, United Arab Emirates. They understand the culture, and they provide the human intelligence, which is the crucial and dangerous part. The Americans provide the electronic surveillance. The Saudi authorities have said very little about the foiled plot, which was to involve a suicide bomber sewing an explosive into his underwear and detonating it in midair - much like the bombing attempt in late 2009 by a young Nigerian who was also recruited and trained in Yemen. The agent who foiled the plot - apparently by volunteering for the suicide mission himself - is now safely in Saudi Arabia, officials there say. But analysts have speculated that the disclosure may already have damaged Saudi Arabia's carefully cultivated network of informants. Saudi intelligence officials have been deploying agents in Yemen for years, analysts say, in what has become a game of mutual subversion. In 2009 a Saudi member of Al Qaeda's Yemen-based affiliate suddenly returned home and surrendered to the authorities, delivering a blow to the militant network. A few months later, another militant - the brother of the man who American authorities believe designed the underwear device in the recently foiled plot - intended to do the same thing, but instead detonated a bomb concealed inside his body on his arrival. His target, the kingdom's top counterterrorism official, Prince Mohammed bin Nayef, narrowly escaped death. "Your success last time becomes your failure the next time," said Gregory Johnsen, a Yemen scholar at Princeton University. Both sides are constantly adapting and learning from each other. Most of this struggle takes place in the shadows, but occasional glimpses emerge in the frequent bulletins released by Al Qaeda's Yemeni branch and its allied group, Ansar al-Shariah. The accused Saudi spy executed in March was one in a batch of three, and his execution video was accompanied by footage of all three men confessing to being paid by Yemeni or Saudi authorities. The confessions - which cannot be verified and could well have been produced under duress - include claims that the men provided information that helped American drones target and kill Yemeni militants. A number of similar videos were released last year. The espionage has grown even more dangerous since last year, when political turmoil in the Yemeni capital of Sana allowed the militants to carve out a much broader swath of territory in south Yemen and even to build training camps, according to American officials. The American campaign of drone strikes has also stepped up, and on Sunday yielded a significant victory: the killing of Fahd al-Quso, a high-ranking member of Al Qaeda's Yemeni branch who was wanted by the F.B.I. for his role in the 2000 bombing of the U.S.S. Cole.