SANAA, Yemen - Facing growing calls for his resignation, Yemen's longtime ruler told tens of thousands of supporters Friday that he's ready to step down but only if he can leave the country in "safe hands," while anti-government protesters massed for a rival rally.

President Ali Abdullah Saleh spoke in a rare appearance before a cheering crowd outside his presidential palace in the Yemeni capital.

Across town, an even larger number of people converged on a square in front of Sanaa University chanting slogans calling for his ouster and waving red cards emblazoned with the word "leave" despite fears of more violence a week after government security forces shot dead more than 40 demonstrators in the capital.

Protesters carried through the square the bodies of two protesters wounded in last week's shooting who recently died of their wounds, their coffins draped with Yemeni flags. Demonstrators prayed over the bodies and chanted to the president, "Everyone who falls as a martyr shakes your throne, o Ali!" as the bodies were taken for burial.

Armed with assault rifles, soldiers from units that defected to the uprising patrolled the square to protect protesters. Hundreds of people lined up to be searched before entering, many clad in white robes and turbans, with prayer mats tossed over their shoulders for noontime prayers.

"We are trying to gather as many people as possible here. He needs more pressure to leave," said demonstrator Magid Abbas, a 29-year-old physician. "We have great hopes."

Thousands also marched in anti-government protests in two areas of the southern port city of Aden. Security forces dispersed one of the protests with tear gas, participants said.

The bloodshed last Friday prompted a wave of defections by military commanders, ruling party members and others, swelling the ranks of the opposition and leaving the president isolated.

Saleh, in power for nearly 32 years, responded by imposing a state of emergency that allows media censorship and gives authorities wide powers to search homes and arrest, detain suspects without judicial process, censor mail and tap phone lines.

At the same time, he has made gestures trying to appease the protesters, to no avail. Over the past month, he has offered not to run again when his current term ends in 2013, then promised to step down by the end of the year and open a dialogue with the leaders of the demonstrators. That offer was rejected as too little, too late.

Instead protesters have hardened their demands, with youth groups calling for Saleh's immediate ouster, the rewriting of the constitution and the dissolution of parliament, local councils and the notorious security agencies.

Maj. Gen. Ali Mohsen al-Ahmar, a top military official who defected to the opposition this week, met privately with Saleh on Thursday to suggest ways he could leave power, an aide who attended the meeting said.

Saleh rejected the offer, lashing out instead out at the protesters and promising to "cling to constitutional legitimacy" and to use "all means possible" to protect the country.

He appeared to soften his tone on Friday but his harsh descriptions of his opposition suggested continued defiance.

"We in leadership, we don't want power but we need to hand it over to trustful hands, not to sick, hateful, corrupt, collaborator hands," Saleh told his supporters, who carried pictures of the president and signs reading "No to terrorism!"

"We are ready to leave, but we want to do it properly and at the hands of our people who should choose their leaders," he said, calling the opposition a small minority of drug dealers, rebels and illegal money traders.

The remarks recalled a similar statement by ex-Egyptian President Hosni Mubarak who, during the height of the 18-day uprising against his rule, said that he wanted to resign but couldn't for fear the country would sink into chaos. Not long after, Mubarak was ousted on Feb. 11, chased out by protesters who have inspired similar uprisings demanding change in Yemen and several other countries.

Reflecting a gradual crumbling of Saleh's authority across the country, residents of towns in five provinces have taken over local security from police, in some cases stripping them of their guns before letting them leave.

"We have formed popular committees in all the city's neighbourhoods and streets to protect the houses since police left," said activist Nasser Baqazqouz in the southern port city of Mukalla.

Even members of a security force run by Saleh's son surrendered their guns to residents in three towns in Abyan province, security officials said, speaking on condition of anonymity because they were not authorized to talk to the media.

In Sanaa, security forces parked tanks and military vehicles close to the palace and beefed up their presence around Saleh's ruling party building and the Interior Ministry.

As he spoke, Saleh's forces tried to prevent more anti-government demonstrators from entering Sanaa. Troops manning checkpoints on roads leading to the capital searched cars, trying to identify protesters, said a demonstrator who was turned away, Hamid al-Hawlani.

"We were in a car of some 25 people, but soldiers told us that the capital was closed," said al-Hawlani, whose tribe has joined anti-Saleh protests. "They said we could come after the protests end."

Protesters who had called for a million people to gather in Sanaa on Friday -- the day of weekly Muslim communal prayers at mosques -- also stepped up security around the downtown square where they have held demonstrations for weeks.

They have vowed to stay put in the traffic circle outside Sanaa University they have optimistically renamed "Taghyir" -- or "Change" -- Square.

Tents were emblazoned with the pictures of demonstrators killed last week. Volunteers handed out red cards, a joking reference to the soccer penalty of ejecting a player from the game.

Many demonstrators wrapped red bandannas around their heads with the word "leave," while children had their faces painted in the red-white-and-black colours of the Yemeni flag.

"We are at a crossroads today," a man shouted into a loudspeaker, with amplifiers strung across the areas. "May God make us victorious against these corrupt oppressors!"