Thousands of migrants are fleeing South Africa after weeks of anti-foreigner violence culminated in chaotic protests across the country, forcing families to abandon their homes, businesses and possessions amid fears they would be killed.

Protesters have told all undocumented foreigners to leave South Africa by Tuesday, ahead of anti-immigrant rallies that many fear will turn violent.

A movement has given migrants until June 30 to leave