BEIRUT -- Civilians trapped in a Palestinian refugee camp in Syria's capital fled to safer areas Saturday amid intense shelling and clashes between Palestinian armed factions and Islamic militants who took over most of the camp, Syrian activists said.

A Damascus-based Palestinian official, Khaled Abdul-Majid, said the militants controlled about half of the Yarmouk camp, located on the southern edge of the Syrian capital.

Islamic State militants stormed the camp on Wednesday, marking the extremist group's deepest foray yet into the capital. Palestinian officials and Syrian activists said they were working with rivals from the al Qaeda affiliate in Syria, the Nusra Front. The two groups have fought bloody battles against each other in other parts of Syria, but appear to be co-operating in the attack on Yarmouk.

The Islamic State group's presence in Yarmouk gives it an important foothold only a few kilometres away from President Bashar Assad's seat of power. It also gives the group a potential sanctuary where U.S.-led coalition forces were unlikely to strike because of the camp's proximity to Damascus.

The United Nations says around 18,000 civilians, including a large number of children, are trapped in Yarmouk. The camp has been under government siege for nearly two years, leading to starvation and illnesses caused by lack of medical aid. The camp has also witnessed several rounds of ferocious and deadly fighting between government forces and militants.

Most of the camp's estimated 160,000 inhabitants fled in late 2012 as clashes erupted between pro- and anti-Assad Palestinian gunmen-- many to overcrowded and destitute Palestinian refugee camps in neighbouring Lebanon. Only the poorest remained behind.

UN aid workers have been sending food parcels into the camp in an effort to alleviate the extreme suffering inside.

After militants advanced into northeastern districts of the camp overnight Saturday, many residents fled the fighting to safer districts in the south, activists said. Islamic State militants took up sniper positions on rooftops, they added.

An activist based in an area just south of Damascus, Hatem al-Dimashqi, said Saturday that rebel groups have launched a counteroffensive aimed at ousting the militants from the camp. He said a number of factions based inside the camp and in surrounding areas, including Yalda, Babila and Beit Saham, formed a joint operations command to co-ordinate their military action.

Al-Dimashqi, speaking from the edge of Yalda, said mosques in those areas were blaring calls for blood donations as hospitals received wounded civilians from Yarmouk.

He and the Palestinian official, Abdul-Majid, said IS militants beheaded five people, some of them from the anti-Assad group known as Aknaf Beit al-Maqdis which has fought them in the camp.

The coalition has been striking at Islamic State militants and infrastructure in north and eastern Syria, where the group has its strongholds.

In addition to the ground clashes, Syrian forces were shelling the camp. The Syrian Observatory for Human Rights reported Syrian government airstrikes on Yarmouk, but said there was no immediate word on casualties.

The Syrian National Coalition opposition group accused the government, which has blockaded the camp from three sides, of allowing militants access into the camp. It called for urgent intervention by the UN and Arab League to provide humanitarian corridors to evacuate civilians.