Migrant Mamoudou Gassama was filmed racing up an apartment building to save a dangling toddler about to fall.

A Malian man in France has been hailed a hero and granted French citizenship after he scaled an apartment building to rescue a child dangling off a balcony.

French President Emmanuel Macron announced that Mamoudou Gassama, an undocumented migrant, would become a “naturalised French” national and join the fire service, the AFP news agency reported on Monday.

Gassama was filmed by crowds on the ground as he quickly climbed up four balconies to reach the toddler in distress.

A couple in the neighbouring apartment, located in Paris’ 18th Arrondissement, were trying to reach the child but were unable to lift the boy over to their side safely.

When Gassama reached the child and pulled him to safety, the crowds gathered below broke out into rapturous applause.

He later told French media he loved children and “wouldn’t have wanted something to happen to him”.

“I managed to get up to the balcony above. I went up like that. And thank God, I saved him,” Gassama said.

According to his brother, Gassama did not have the necessary papers to take up residency in France and had been living in temporary accommodations.

Before Macron’s announcement, officials hinted that the situation could change.

A government spokesperson said the country should “open the doors of our national community”, and Paris Mayor Anne Hidalgo added the city was eager to support efforts to settle him in France.

Un grand bravo à Mamoudou Gassama pour son acte de bravoure qui a permis de sauver hier soir la vie d'un enfant. J'ai eu plaisir à m'entretenir avec lui aujourd'hui par téléphone, afin de le remercier chaleureusement. https://t.co/DP5vQ1VZYh — Anne Hidalgo (@Anne_Hidalgo) May 27, 2018

Translation: A big bravo to Mamoudou Gassama for his bravery that saved a child’s life last night. I was pleased to have spoken to him today on the phone to thank him warmly.

Gassama’s efforts have turned him into a phenomenon on social media, where he has been described as “the Spiderman”.