U.N relief workers in April 2014 with blue helmets with residents of the besieged Palestinian camp of Yarmouk in Damascus, Syria. Refugees fled to safer areas Saturday amid intense shelling. ( /United Nations Relief and Works Agency for Palestine Refugees in the Near East via AP)

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 Islamist militants who have taken over most of the camp, Syrian activists said.

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

Islamic State militants stormed the camp 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, Jabhat al-Nusra, also known as the al-Nusra Front. The two groups have fought each other in other parts of Syria but appear to be cooperating in the attack on Yarmouk.

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

The United Nations said 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.

A handout picture made available by the official Syrian Arab News Agency is said to show Syrian citizens waiting to receive relief aid from Syrian Arab Red Crescent and International Red Cross that distribute aid to the towns of Yalda, Babbila and Beit Sahem in rural Damascus. (Sana Handout/EPA)

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 neighboring Lebanon. Only the poorest remained behind.

U.N. 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 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 both inside and outside the camp have launched a counteroffensive to oust the militants from the camp.

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.

— Associated Press