SANAA (Reuters) - Yemen's president and opposition, pressed by Western and Gulf mediators, agreed in principle on Wednesday to sign a transition of power deal to end the rule of Ali Abdullah Saleh within a month, an opposition official said.
But in a familiar twist, last-minute snags appeared to be holding up the deal that would grant Saleh immunity from prosecution, allowing him a dignified exit from power in the Arabian Peninsula state that he has ruled for nearly 33 years.
"After American, European and Gulf efforts, there was agreement by the president on the Gulf initiative after simple changes, and the signing will be today," opposition official Yahya Abu Usbua said.
Al Arabiya television quoted an adviser to Saleh as confirming the signing would take place on Wednesday.
Sources close to the negotiations later said Western and Gulf diplomats were engaged in shuttle diplomacy to try to overcome differences over who would sign and when and where. They said diplomats were insisting the deal be signed on Wednesday.
The United States and oil giant Saudi Arabia, both targets of foiled attacks from al Qaeda's Yemen wing, are keen to see an end to Yemen's political stalemate, fearing continued chaos could give the militant group more room to operate freely.
Some political analysts doubt whether the deal, which would help end three months of street anti-Saleh protests that have paralysed Yemen's economy, would actually be carried out. Two previous near-deals fell through at the last minute.
"I won't believe it until I see it, that's what we learned in Yemen ... Everyone thought that the deal was done a few weeks ago but Saleh found a way to back out in final hours and days." said Shadi Hamid, analyst at the Brookings Doha Centre.
"Saleh is notoriously stubborn. If he signs maybe we'll actually see a conclusion to the crisis in Yemen and that's what people have been waiting for."
Abdullatif al-Zayani, who heads the Gulf Cooperation Council of Yemen's wealthy oil-exporting Gulf neighbours, has been in Sanaa since Saturday trying to persuade the sides to sign the Gulf-led deal, with help from U.S. and European diplomats.
Qatar, a key member of the six-state bloc, had earlier backed out of the Gulf initiative, citing stalling and "lack of wisdom".
Saleh, a shrewd political survivor who has outlasted previous opponents' attempts to challenge his power, indicated in April he would sign the Gulf-brokered deal, but refused to put his name to it in the final hours.
He said at the time he would only sign in his capacity as ruling party leader, not as president.
The opposition, whose coalition includes Islamists and leftists, said there had been minor modifications to the Gulf initiative agreed on Wednesday, including changes in who would sign for each side and in what capacity.
"The president will sign for the government in his capacity as president of the republic and as head of the ruling party," the opposition's Abu Usbua said.
Negotiations were still ongoing on who would sign on behalf of the opposition, with the sides disagreeing on the matter, opposition sources said.
Protesters, frustrated that their daily rallies have failed to dislodge Saleh, want the 69-year-old leader out immediately and have said they will step up their campaign by marching on government buildings, a move that brought new bloodshed last week as security forces fired to stop them.
"This agreement will annihilate the revolution because Saleh will not implement it," Sanaa activist Meshaal Mujahid said of the new deal. "If it took over a month to sign, how much time do we need for Saleh to submit his resignation?"
Yemeni political analyst Abdul-Ghani al-Iryani said the deal would reduce tension that could erupt into clashes between military units loyal to Saleh and those backing the protesters.
"What is important about it is that it allows the opportunity to diffuse the military tension," he said.
Protesters blocked the entrance of the Red Sea port of Hudaida, Yemen's second largest port, blocking traffic from entering or leaving, protesters said. The cities of Ibb, Taiz and Hadramout were brought to a standstill as most workers complied with a strike aimed at pressuring Saleh to leave.
Additional reporting by Sara Anabtawi and Mahmoud Habboush in Dubai; Writing by Cynthia Johnston; Editing by Matthew Jones