The incident took place at around 8:00 pm (1800 GMT) on Saturday in northern Paris.
Film of the rescue shows Gassama, 22, pulling himself up from balcony to balcony with his bare hands as a man on the fourth floor tries to hold on to the child by leaning across from a neighbouring balcony.
On reaching the fourth floor Gassama puts one leg over the balcony before reaching out with his right arm and grabbing the child.
Firefighters arrived at the scene to find the child had already been rescued.
“Luckily, there was someone who was physically fit and who had the courage to go and get the child,” a fire service spokesman told AFP.
Paris mayor Anne Hidalgo praised the young migrant on Twitter for his “act of bravery” as well as phoning him personally to “thank him warmly”.
“He explained to me that he had arrived from Mali a few months ago dreaming of building his life here.
“I told him that his heroic act is an example to all citizens and that the city of Paris will obviously be very keen to support him in his efforts to settle in France,” she added.
The young Malian will next be honoured for his brave rescue by French President Emmanuel Macron who has invited him to the Elysee Palace on Monday, his office told AFP.
Tracked down by reporters 24 hours after the heroic rescue, Gassama said he had acted without thinking.
“I saw all these people shouting, and cars sounding their horns. I climbed up like that and, thank God, I saved the child,” he said.
“I felt afraid when I saved the child… (when) we went into the living room, I started to shake, I could hardly stand up, I had to sit down,” he added.
According to initial inquiries by the authorities, the child’s parents were not at home at the time.
The father was later held for questioning by police for having left his child unattended and was due in court later, a judicial source said. The child’s mother was not in Paris at the time.