Johannesburg: A wave of xenophobic attacks escalated in South Africa's seething townships on Monday, with mobs beating foreigners and setting some ablaze in scenes reminiscent of apartheid era violence.

The unrest has killed at least 22 people since last week and increased political instability at a time South Africa is struggling with dire power shortages, rising inflation and growing disaffection among the poor over President Thabo Mbeki's pro-business policies.

Police fired rubber bullets at rioters in communities around Johannesburg and in the central business district.

Armed with knives, clubs and jugs of petrol, the mobs targeted mostly Zimbabweans and Mozambicans, the biggest groups among immigrants who are accused by the poor of taking jobs and fuelling the high rate of violent crime.

Women were raped, shops and homes looted and dozens of shacks burnt to the ground. Scores have been arrested.

"This is a war," said Lucas Zimila, a 60-year-old Mozambican man who was attacked by a machete-wielding mob while sleeping in his shack in Tembisa, north of Johannesburg, on Sunday night.

"They screamed at me to get out, that I didn't belong here. Then they burned everything in my house," said Zimila, who suffered a five-inch gash in his head.

Gangs of men armed with guns, clubs and threats have chased thousands of Zimbabweans and other foreigners from their homes in this nation's poor townships over the past week, leaving at least 12 people dead and scores injured, according to news reports.

The nighttime rampages have turned police stations in several townships in the Johannesburg area into virtual refugee camps, with makeshift tents, portable toilets and clusters of terrified people, many displaying wounds from the attacks.

Many have vowed never to return to their looted houses but have few options when their own nations are experiencing a dearth of economic opportunities, or, in the case of Zimbabwe, a devastating political crisis and inflation that has topped 165,000 per cent.