More than 1,000 migrants who fled fighting in Libya have been left without shelter in the Tunisian desert after locals burned and looted a refugee camp near the border, witnesses have claimed.

At least five people were wounded when Tunisian soldiers opened fire on migrants fleeing Tuesday's attack on the UN-managed Choucha camp near the main crossing with Libya at Ras Ajdir, said Alganesc Fessaha, an Eritrean doctor who treated the victims.

The attack left around 1,500 residents without shelter. It reflected growing resentment among Tunisians against the migrants, mainly workers from Eritrea, Somalia and Ivory Coast.

Tensions between the two groups came to a head after refugees blockaded the road to the border to protest against being held in the camp, four miles from the border.

Locals then attacked the protesters with clubs and iron bars before Tunisian troops fired teargas and warning shots in an attempt to break up the fighting.

But a mob of about 300 Tunisians then attacked the camp, burning down about half the tents, Fessaha told the Guardian. "Eritreans fleeing from the camp as it burned were beaten by locals lined up and waiting with iron bars," said Fessaha, who was also attacked as she entered the camp.

Fessaha was treating the the gunshot wounds of five Sudanese men who said they had been shot by Tunisian soldiers. "The soldiers shot at us as we fled the camp," said Abu Bakr Osman Mohammed, 39, who spent three years working in Libya and two in jail for illegal immigration before escaping as the conflict started.

"It is a miracle no one was killed," said Father Sandro De Pretis, an Italian priest based in Tripoli who is involved in the aid operation.

"They came in daylight, well organised, and the army did nothing to protect the camp dwellers and may have even provided an escort as the locals burned what they could not steal. Something has to be done now for these migrants stranded in the sand." De Pretis said the attack marked a change in the mood of Tunisians, who hitherto had offered hospitality to refugees streaming over the border, even as they struggled to rebuild their own economy after this year's popular uprising.

After first hosting Pakistanis and Bangladeshis who have now been repatriated, Choucha is now home to 3,300 Africans – including dozens saved from a leaking boat as they tried to make the perilous sea crossing to Italy earlier this month.

"At first the Tunisians brought food to the refugees but yesterday they were out of their minds," said De Pretis.

Father Mosé Zerai, the head of an asylum seekers' organisation in Italy, said tensions in the camp had risen after a group of Sudanese men tried to rape an Eritrean woman last week.

"The Eritreans defended the girl and the Sudanese burned down their tents in revenge," he said.

Four Eritreans died on Sunday night as 21 tents burned down, triggering demonstrations over conditions in the camp.

Zerai said the roadblock was led by west Africans, including Nigerians, who are less likely to be granted asylum status and feared they would be repatriated. "They were already unhappy, but after the first fire their anger exploded," he said.Two people reportedly died in the first clashes on the road on Monday. "The protest was very stupid, since it halted business travel," said De Pretis. "The army did nothing and the locals took the law into their own hands."

Threats by the west Africans then prompted the UN to withdraw all its staff from the camp on Monday, with one UN official describing a "general atmosphere of lawlessness in the camp".

"When the Tunisians came, the UN wasn't there," said De Pretis.

On Wednesday, officials were counting the wounded and rounding up families without shelter as apparent calm returned to the camp. The defence minister, Abdul-Karim al-Zubaidi, toured the camp as the police and military presence was strengthened.

"On Tuesday night, all the 3,000 or so people in the camp, even those who still had shelter, slept outdoors because they were terrified of being burned alive in their tents," said Fessaha.

Staff from the UN's refugee agency who were touring the camp on Wednesday could not be reached for comment. In Geneva, spokeswoman Sybella Wilkes said: "There is a large group of refugees in the camp who have gone through hell and that is now being compounded by their insecure position there." But according to De Pretis, the return of UN staff had done little to reassure the camp's inhabitants. "There are plenty of women and children here and we are out in the desert," said Fessaha. "You just have to say hello and you get a kilo of sand in your mouth."