A fire has devastated one of the most crowded neighbourhoods of Johannesburg, destroying 500 homes and leaving thousands of people homeless.

The fire broke out late on Thursday afternoon in Alexandra, a township in the South African city that is home to more than 400,000 people.

“On arriving at the scene the firefighters were met with an inferno and immediately began to evacuate the residents in the area to safety,” said Michael Sun from the mayor’s office.

Thick black smoke rose from Alex, as the neighbourhood is known, as the fire roared below. Three fire engines were sent to the scene but the only nearby fire hydrant had low water pressure and the engines had to ferry water back and forth. Sun said shacks were often built on top of hydrants, or they were vandalised.

Donated money, clothes and food flooded into the township on Friday, though some South Africans commented that many of Alexandra’s residents were foreigners, in echoes of the xenophobic riots that have split communities and seen immigrants attacked across the country.

Local organisations put out calls for help and donations of corrugated iron sheets, mattresses and beds.

People left with only the clothes they were wearing began to rebuild their shacks – flimsy structures often made of wood, cardboard and plastic sheeting. One new mother told Eyewitness News that she had just arrived home after delivering a baby boy when a neighbour ran to tell her that the fire had broken out.

Divided cities: South Africa's apartheid legacy photographed by drone Read more

“I took my baby and ran away because of the smoke. I lost everything. I don’t have clothes. I don’t have anything,” she said.

Facebook Twitter Pinterest A boy walks between the shacks of Alexandra – one of the most crowded neighbourhoods in South Africa’s largest city. Photograph: Kim Ludbrook/EPA

A man accused of starting the fire was apparently attacked so badly that he later died in hospital, and police have opened a murder case.

“Initially we opened a case of attempted murder but now we are changing it to murder,” local media reported Mavela Masondo, a police spokesman, as saying. “We are still appealing to the community ... to those that witnessed the incident to please come forward and give us information or give us a statement.”

Alexandra, which sits next to Sandton, one of Johannesburg’s richest areas, has often been threatened with demolition since it was first established in 1912. But it survived the apartheid period, where other black areas in white suburbs were often bulldozed. This was because of a friendship between two church ministers: one was Sam Buti who ran the Save Alex campaign in the 1970s, and the other was the then minister of cooperation and development, Piet Koornhof.

Nelson Mandela rented a room there in the 1940s at the age of 23, when he was working as a legal clerk and completing his degree.