A deadly fire in Johannesburg's inner city was "a wake-up call" for South Africa, says President Cyril Ramaphosa.
Seventy-four people were killed - including 12 children - after a blaze in a five-storey building, which was being occupied by homeless people.
More than 50 others were injured.
Earlier, the city of Johannesburg confirmed it owned the building, but said cartels had taken it over. Officials say the cause of the deadly fire is unclear.
In a news conference at the site of the fire, Mr Ramaphosa said the incident needed to be investigated and lessons learnt to prevent future tragedies.
"It's a wake-up call for us to begin to address the situation of housing in the inner city," the South African leader said.
The building used to be a home for abused women and children, but once the lease expired, it was "hijacked", President Ramaphosa explained to reporters.
Many properties around the area where the blaze happened have been deemed unfit to live in.
Yet these old blocks, abandoned by their owners or the city authorities, are full of families, often paying rent to criminal gangs who run them.
Some of those who use the buildings include undocumented migrants, mostly from other African countries.
The buildings, which lack running water, toilets or a legal electricity connection, are then said to have been "hijacked".
South Africa faces a chronic housing shortage, with an estimated 15,000 people estimated to be homeless in Johannesburg.
"We need to get on top of this and find effective ways of dealing with problems of accommodation, of housing, and services in the inner city," Mr Ramaphosa added.
He also commended emergency services, who arrived at the scene 10 minutes after the fire was reported.
Johannesburg city manager Floyd Brink said 200 families were affected by the fire and "all efforts" were taken to provide accommodation.
A spokesman for the emergency services, Robert Mulaudzi, told the BBC that the fire had gutted the building but firefighters had been able to bring out some of the occupants.
He explained that because the building was not properly looked after, makeshift structures and debris had made it hard to search for and rescue people.
A video posted by Mr Mulaudzi to the platform X, formerly known as Twitter, showed fire trucks and ambulances outside the building with burnt-out windows.
Photos from the scene showed covered bodies lined up near the burned building.
One woman told journalists she was outside the building searching for her 24-year-old daughter.
"As soon as I heard the building was burning down, I knew I had to run here to come and look for her," she said.
"Now that I'm here, I'm kept in suspense because I really don't know what is happening. I don't get any direction - so I'm actually very anxious, I don't know if my daughter is alive."
In a visit to the scene, Johannesburg mayor Kabelo Gwamanda said Johannesburg officials would relocate people living in similar "hijacked" buildings in the city, and turn those buildings into social housing. "We are not going there with brute force," he told reporters, "we are trying to apply a sensitive strategy."
Asked whether his administration would take responsibility for the tragedy, Mr Gwamanda said the government was dealing with the issue of cartels hijacking buildings, which was taking place across the city.
In the wake of the fire, many South Africans on social media condemned the online xenophobic attacks that some have made against the victims and survivors of the fire.
Additional reporting by Malu Cursino in London.
Are you in the area? Did you witness the incident? If it is safe to do so, get in touch by emailing email@example.com.
Please include a contact number if you are willing to speak to a BBC journalist. You can also get in touch in the following ways:
WhatsApp: +44 7756 165803
If you are reading this page and can't see the form you will need to visit the mobile version of the BBC website to submit your question or comment or you can email us at HaveYourSay@bbc.co.uk. Please include your name, age and location with any submission.