(CNN) -- After months of bloodshed, intrigue and revenge that made Yemen seem like an Arabian version of Hamlet, President Ali Abdullah Saleh has finally transferred his powers to his vice president, and elections are to be held in three months.





At the ceremony in Riyadh, Saudi Arabia, to seal the transition deal worked out by the Gulf Cooperation Council, Saleh seemed relaxed and even chuckled as he signed several copies of the agreement, the result of intense diplomatic shuttling by U.N. envoy Jamal bin Omar and growing pressure from the international community.





But Saleh also took a parting shot at his opponents, saying they had destroyed in months everything that had been built over years.





April Longley Alley, Yemen analyst at the International Crisis Group, says the Riyadh deal offers an "opportunity to move past the current political impasse and to deal with critical issues like deteriorating economic and humanitarian conditions as well as the very difficult task of institutional reform."





Even so, Longley Alley and other analysts expect the epilogue to be anything but predictable. There are plenty of competing elements left behind: the thousands of mainly young demonstrators who took to the streets of Sanaa and other cities in January to demand democratic change, the tribal alliance that took up arms against Saleh, secessionists in the south and a Shiite rebellion in the north, well-organized Islamist groups and a budding al Qaeda franchise.





Perhaps the most powerful figure in Yemen now is Brig. Gen. Ali Mohsen al-Ahmar, commander of the 1st Armored Division. He defected in March and took a chunk of the army with him. His units now control northern districts of the capital and are facing off against powerful remnants of the Saleh clan. The president's son, Ahmed Ali Abdullah Saleh, long groomed to be his successor, and his nephew, Yahya Muhammad Saleh, command the most effective units.





Longley Alley says the Gulf Cooperation Council accord "does not deal effectively with lingering tensions between Saleh's family on one hand and Ali Mohsen al-Ahmar and the powerful al-Ahmar family on the other. Each of these power centers is heavily armed and still poised to fight."





As if to remind the diplomats of the scale of the task ahead, pro- and anti-Saleh factions clashed in Sanaa hours before the ceremony. The challenge of "securing a cease-fire, removing armed tribesmen from urban centers, returning the military to the barracks and engaging in military-security reform will be serious stumbling blocks post-signing," according to Longley Alley.





Al-Ahmar makes some Western officials nervous because of his links with radical Sunni Islamists. Yemeni observers say the Muslim Brotherhood has long been influential within al-Ahmar's military command, and he is known for his antipathy toward Yemen's Shiites. A U.S. diplomatic cable from 2005 said that "Ali Mohsen's questionable dealings with terrorists and extremists would make his accession unwelcome to the U.S. and others in the international community."





Others in this powerful clan include Hamid al-Ahmar, a leader of the Islamist party Islah and a prominent businessman who has long been an opponent of the president. His brother Sadiq also has armed supporters in and around Sanaa.





For generations, the Yemeni state has done little without the al-Ahmars' blessing. Sheikh Abdullah Bin Hussein al-Ahmar, who died in 2007, was one of the few Yemenis to command widespread respect -- a man often described as the father of modern Yemen. He was an opposition leader but also speaker of the Parliament, and Saleh was careful not to cross him. Today, there seems no one of similar stature.





The tens of thousands of demonstrators who have braved gunfire, tear gas and pro-government gangs in Sanaa, Taiz and elsewhere are unlikely to be satisfied by Saleh's departure. They fear being marginalized by the transfer of power from one clique to another as part of some "tribal bargain" and oppose Saleh's immunity from prosecution, which is part of the Riyadh deal.





But Longley Alley says they have a role to play. "The independent youth in Yemen have at times been marginalized by the armed conflict
Which country did he leave? What is the number of demonstrators? How many demonstrators were there? Who departed from Yemen? Which families remain at odds with each other? Which two families are at odds? How many anti-Saleh demonstrators are there?
Yemen thousands tens of thousands President Ali Abdullah Saleh Saleh's Saleh's family on one hand and Ali Mohsen al-Ahmar and the powerful al-Ahmar family on the other. tens of thousands
question: Which country did he leave?, answer: Yemen | question: What is the number of demonstrators?, answer: thousands | question: How many demonstrators were there?, answer: tens of thousands | question: Who departed from Yemen?, answer: President Ali Abdullah Saleh | question: Which families remain at odds with each other?, answer: Saleh's | question: Which two families are at odds?, answer: Saleh's family on one hand and Ali Mohsen al-Ahmar and the powerful al-Ahmar family on the other. | question: How many anti-Saleh demonstrators are there?, answer: tens of thousands