A soldier helping police quell violence against foreigners in South Africa shot and killed a man who was attacking a woman, the military said Saturday, as hundreds more immigrants fled the country.

Police also fired rubber bullets to disperse crowds as sporadic violence and looting were reported across the country in the latest disturbances, which have left at least 42 people dead and more than 25,000 foreigners displaced this month.

Much of the violence is fueled by resentment of immigrants competing for scarce jobs and housing. Others blame foreigners for crime. Seeking to calm the unrest, President Thabo Mbeki called in the army on Wednesday for the first time since the end of apartheid in 1994 to aid police.

Click here for photos.

Mbeki condemned the violence, saying during an appearance at a school in eastern South Africa that it disgraced the legacy of the liberation struggle, the state broadcaster reported Saturday.

On Friday night, soldiers supporting police east of Johannesburg saw a man assaulting a woman, Brig. Gen. Kwena Mangope said. As they approached, the man pointed a gun at the soldier, who then shot the man, Mangope said.

It was not clear whether the assault on the woman was related to the recent violence against foreigners or was a domestic dispute.

Mangope said the incident was "unfortunate" and police are investigating.

Safety and Security Minister Charles Nqakula acknowledged this week that putting soldiers on the streets was sensitive since they were trained to kill, not to enforce the law. He said they would only support police, who have made more than 500 arrests linked to the anti-foreigner violence.

The minister visited several hot spots with a high-level government delegation Saturday. His spokesman said he had no immediate comment on the killing by a soldier.

The center of the violence has been the country's smallest but richest province of Gauteng, which includes Johannesburg.

Gauteng provincial police spokesman Govindsamy Mariemuthoo said there were a number of minor incidents overnight in the province's East Rand area, which has seen the worst of the violence.

He said police used rubber bullets to disperse crowds but no deaths were reported.

By Friday, violence had spread to at least seven of the country's nine provinces as well as the popular tourist destinations of Cape Town and Durban.

A Cape Town police spokesman, Andre Traut, said police had been called to a number of areas overnight to stop looting of shops and help move foreigners.

"But everything is back to normal now and there is no violence," Traut said.

About 200 people have been arrested while about 1,200 people had been displaced in Cape Town, he said.

While the violence was dying down, thousands of displaced remained in camps, and foreigners were streaming back to their home countries.

Immigration officials in neighboring Mozambique said 2,000 Mozambicans crossed back home Saturday morning. In total, the number of Mozambican immigrants who have fled South Africa now stands at 16,000, and more were expected.

"We have received calls from our embassy ... telling us about further influx of immigrants, in thousands," said Mauricio Mponda, an immigration official working at a main crossing point from South Africa.

The Mozambican government has set up two camps to accommodate the victims of the violence, according to the foreign minister, Oldemiro Baloi.

Mozambique declared a state of emergency Thursday, leading to the release of money and aid to help those fleeing the violence in South Africa. Mozambique is still assessing the needs of those returning and has not said how much money would be released.

Malawi, another South African neighbor, said Friday it had rented a bus to bring citizens home from South Africa. Deputy Information Minister John Bande said Malawian diplomats in South Africa had received distress calls from about 850 Malawians.

Some Malawians have made it home on their own. Jacqueline Charles, nursing a 2-year-old boy, said she had to flee and leave all her property after a crowd of machete-wielding young men attacked her house.

"Things are not good down there," she said as she got off a bus in Blantyre, Malawi, Friday. "We have lost everything, we just ran with our lives."

Another passenger, William Maluwa, showed a bandaged head, and said he had been hacked "savagely."