SANAA, Yemen -- Yemen's embattled president on Sunday resisted intense U.S. and Arab pressure and stalled at signing a deal calling for him to step down in 30 days, as his regime brought armed supporters into the streets demanding he stay. Hundreds of militiamen trapped the American and other ambassadors inside a diplomatic mission for hours.

The militiamen, armed with knives and swords, blocked the entrances to the United Arab Emirates Embassy, where at least five U.S., European and Arab ambassadors had gathered, expecting President Ali Abdullah Saleh to arrive to sign the agreement.

Finally in the evening, Yemeni military helicopters landed at the embassy and ferried the diplomats out, taking them to the presidential palace. There they witnessed several Yemeni ruling party officials sign the accord. But Saleh, shown on state TV standing alongside the U.S. ambassador, did not sign.

Saleh said afterward he would not do so unless opposition leaders attend and sign it as well in public, not "behind closed doors."

"If they don't comply, they are dragging us to a civil war, and they will have to hold responsibility for the bloodshed in the past and the blood which will be spilled later on because of their stupidity," Saleh warned in an address on state TV.

The developments threatened to wreck a U.S.-backed, Gulf Arab-mediated accord that diplomats hope could resolve the turmoil that has raged in Yemen for the past three months, with tens of thousands of protesters demanding Saleh step down after 32 years in power, and his regime unleashing a deadly crackdown. The accord calls for Saleh to step down in 30 days and hand power to his vice president, in return for immunity from prosecution.

A coalition of opposition parties signed the agreement in private on Saturday, and Saleh promised to sign it the following day.

Saleh has backed away from signing the deal at least twice before, adding to the opposition's deep mistrust of a leader known for adept political maneuvering that has kept him in power for decades. A Gulf official in the Saudi capital, Riyadh, warned that the Gulf Cooperation Council, the regional body that mediated the deal, would withdraw from mediation if Saleh did not sign by the end of the day Sunday.

Throughout the day Sunday, hundreds of armed Saleh loyalists deployed in the streets of the capital Sanaa in what appeared to be a campaign orchestrated by his own regime, aiming to show that the public wants him to stay.

Dozens gathered in front of the police academy, where the ruling party general assembly had convened to discuss the deal. "We are coming under pressure, to reject the initiative," said Mohammed Saad, a member of the assembly. Others erected a big tent in one of Sanaa's main streets, blocking traffic and raising banners that read: "Don't go, don't sign!"

Another armed crowd blocked the road in front of the presidential palace, chanting, "We will not permit the president's ouster."

The diciest moment came when hundreds of Saleh loyalists, touting swords and knives, massed outside the UAE Embassy. They blocked its two main entrances, and at one point attacked a convoy bringing the GCC's chief mediator, secretary-general Abdullatif bin Rashid al-Zayani, to the building. They pounded on the car, tried to prevent it from entering the compound and shouted against Gulf intervention in Yemeni affairs, witnesses said.

"Everybody is worried. We can't leave the embassy," said a Saudi diplomat inside the mission before army helicopters plucked the ambassadors out of the compound. The diplomat spoke on condition of anonymity because of the sensitivity of the subject.

Other loyalists demonstrated outside other foreign embassies. The convoy of the Chinese ambassador also came under attack by armed men before a police detail was deployed to clear the way and disperse the crowd.

On Saturday -- even as he grudgingly promised to sign -- Saleh condemned the proposed deal as "a coup" and warned the U.S. and Europe that his departure would open the door for Al Qaeda to seize control of the fragile nation on the edge of Arabia.

His stalling on signing could throw Yemen deeper into turmoil. Saleh has managed to cling to power despite near daily protests by tens of thousands of Yemenis fed up with corruption and poverty. Like other anti-government movements sweeping the Arab world, they took inspiration from the popular uprisings in Tunisia and Egypt.

The president has swung between offering concessions, taking them back and executing a violent crackdown that has killed more than 150 people, according to the opposition, which says it compiled the tally from lists of the dead at hospitals around the nation.

Saleh has survived despite mass defections by ruling party members, lawmakers, Cabinet ministers and senior diplomats. Saleh's own tribe has joined those demanding his ouster. Several top army commanders, including a longtime confidant who heads a powerful armored division, joined the opposition and deployed their tanks in the streets of Sanaa to protect the protesters.

But Saleh has kept the loyalty of Yemen's most highly trained and best-equipped military units, which are led by close family members.

That has raised concerns the political crisis could turn into an armed clash between the rival military forces if a deal is further delayed.

Seeking to win some support in the West for his continued rule, Saleh has warned several times that without him, Al Qaeda would take control of the country.

The United States, which had supported Saleh with financial aid and military equipment to fight the country's dangerous Al Qaeda branch, has backed away from the embattled leader.

Al Qaeda in the Arabian Peninsula has an estimated 300 fighters in Yemen and has been behind several nearly successful attacks on U.S. targets, including one in which they got a would-be suicide bomber on board a Detroit-bound flight in December 2009. The explosive device, sewn into his underwear, failed to detonate properly.

But even if Saleh signs the accord, it was far from certain whether that would satisfy the many different groups protesting his rule in the streets. Many protesters reject the deal, saying it falls short of their demands he leave immediately and his regime be dismantled. They also reject any immunity for the Yemeni leader and say the opposition parties don't speak for their demands.

Hundreds of thousands poured into a central square Sunday that has become the center of opposition protests, waving Yemeni flags and shouting rejection of the deal. They held banners that read: "Now, now Ali, down with the president!" and "Go out Ali!"

Women mingled with men, unlike in previous protests when female protesters stood on the edge of the square segregated from men, in keeping with Sharia law that mandates separation of the sexes. Children had their faces painted with Yemeni flags, while youths carried pictures of slain protesters. Young men and women held a 6-foot-long (2-meter) Yemeni flag.

"This initiative is only meant to save Ali not Yemen. We are going to continue our revolution until the end. Like Tunisia and Egypt, we will go against the opposition if they form a government while Saleh is still in power," declared Tawakul Karman, a protest leader and senior member of the opposition Islamic fundamentalist Islah Party.