Gunmen killed at least five people protesting against a deal to end the rule of Ali Abdullah Saleh in Yemen's capital on Thursday, a day after the president bowed to pressure and agreed to step down, while the army killed 17 Islamists in the south.

If the deal goes according to plan, Saleh will become the fourth Arab ruler brought down by mass demonstrations that have reshaped the political landscape of the Middle East.

We were marching on Zubayr street demanding Saleh and his followers be tried when we were attacked by armed men in civilian clothes who opened fire on us directly, a protester who identified himself as Nael told Reuters.

The deal, brokered by Yemen's wealthier Gulf neighbours, granted Saleh and his relatives immunity from prosecution.

The latest bloodshed in Sanaa, which witnesses blamed on Saleh loyalists, underscored the volatility of the impoverished country after 10 months of street protests aimed at toppling the leader that brought Yemen to the brink of civil war.

Thursday's shooting followed street clashes between Saleh's foes, once united in protest against him, inspired by the example of revolts in Tunisia, Egypt and then Libya.

The clashes between Saleh's foes pointed to the challenges Yemen faces in a transition away from Saleh's era and the network of his relatives still in positions of military and economic power.

At least 45 people were wounded in the attacks, said Mohammad al-Qubati, director of the field hospital near the square that Yemenis demanding an end to Saleh's 33-rule made the centre of their campaign.

Saleh signed the deal in the presence of Saudi King Abdullah in Riyadh. Saudi Arabia and the United States had urged Saleh to step down as political deadlock over his rule pushed the country towards chaos they feared could embolden Yemen's al Qaeda wing.

Under the deal, whose terms were echoed in a U.N. Security Council resolution, 69-year-old Saleh transfers powers to his deputy before the formation of a new government with opposition parties and early presidential elections.

Hundreds of people have been killed over the course of the demonstrations aimed at toppling Saleh, including many in Sanaa's Change Square, a stretch of the capital's thoroughfare where protesters have lived for nearly a year.

In the south, armed tribesmen freed a French woman and two Yemenis working for the International Committee of the Red Cross (ICRC) on Thursday, two days after they were abducted, Yemeni and French officials said.

In unrest in the south, the army killed 17 Islamist fighters with artillery fire against their positions near Zinjibar, the capital of Abyan province where al Qaeda-linked militants have seized swathes of territory, a local official said.

OUR REVOLUTION

The protesters' solidarity cracked after they appeared to achieve their goal of ousting Saleh. Youth protesters on Thursday turned on an Islamist party, once allied to Saleh, that backed their campaign against him.

Protesters in the square hurled bottles and stones at members of the Islah party, which took part in Saleh governments before throwing its weight against him and courting the protests against him with supplies of food.

The people want the fall of Islah! shouted groups of demonstrators, a play on the slogan demanding the downfall of regimes -- a refrain of the political upheaval rippling through the Arab world since the start of the year.

Fistfights broke out between members of Islah and supporters of the youth groups that shaped the Sanaa protests, which appeared to have secured their goal when Saleh agreed to quit.

The youth organisers deride the coalition of opposition groups that took part in the accord Saleh signed, and call them partners to his crimes and part of a political elite they hope to overthrow completely.

Our revolution, down with Islah! chanted protesters who skirmished with members of the Islamist group.

We will not allow our revolution to be hijacked, Islah should leave the square, said Sami Atfari, a 22-year-old English student.

The political paralysis Yemen has endured in the struggle over Saleh's fate has seen long-standing conflicts with two distinct secessionist movements in the north and south, and another with militant Islamists, stir anew.

Those crises, as well as the position Saleh's son, nephew and other relatives have in controlling key military units and sectors of the country's industry and trade, highlight the challenges any post-Saleh government would face.

You already have Islah and the youth groups fighting one another, and that's apart from the (northern separatist) Houthis and the southern conflict, said Theodore Karasik of the INEGMA thinktank.

As for the relatives, they're supposed to have immunity and to leave their jobs and supposedly fade off into the sunset, he said. But we'll see.|

(Reporting by Mohammed Ghobari and Abdelrahman al-Ansi in Sanaa, and Mohammed Mukhashaf in Aden; Writing by Joseph Logan; editing by Sami Aboudi)