LAGOS (Reuters) - Some 30,000 residents of the Nigerian megacity Lagos have become homeless because of state-ordered demolitions and fighting between rival communities, residents and a rights group said on Thursday.

The violence highlights the challenges of a rapidly rising population unable to provide enough jobs and housing for its 180 million people. Many end up trying to migrate to Europe by boat from lawless Libya.

Africa’s largest economy is in recession as oil revenues have fallen and hard currency reserves dwindled, forcing the closure of plants unable to import raw materials. Every day, thousands head to Lagos, the commercial capital, seeking work in a city of 23 million.

A spokeswoman for Lagos police said officers had arrested several people for setting fire to makeshift houses in the affluent Lekki island district. She denied claims by a Lagos-based rights group, the Justice and Empowerment Initiatives (JEI), that the police had destroyed buildings.

Trouble started when fighting erupted this week between locals and others from Benin, a poor nation just west of Lagos, several residents told a Reuters reporter at the scene, where rows of bamboo buildings had been burned down. Some were still burning.

Bulldozers escorted by police arrived late on Wednesday to raze the traditional housing, JEI said, blaming officers for the conflict.

“Police came ... with caterpillar and started breaking everywhere, putting fire on peoples’ houses,” the group quoted a resident as saying in a statement. “They are seriously beating our people.” Police denied this.

JEI published videos showing people fleeing in boats, an account confirmed by residents.

“Police came at 11 p.m. and ordered us to go. We left by boat,” said a worker called John, who said he had fled with his family. “We have nowhere to go now.”

Lekki is a prime site for investors, who have been building luxury apartments, skyscrapers and waterside restaurants, attracting poor Nigerians and workers from West Africa.

In August, the Lagos state government gave residents who lacked building permits two weeks to move out of Lekki and other up-market districts. JEI said officers had gone ahead with demolitions despite a court order to wait for a hearing.

The Lagos state government could not be reached.

The overcrowding in Lagos looks likely to continue. By 2050, Nigeria’s population is set to more than double to 400 million, making it the world’s third most populous nation after China and India, according to U.N. estimates.