Firefighters were called to the fire, in Admiralty Street, Edinburgh, at 4.37am.
The 15-month-old was taken to Royal Hospital for Sick Children for a check-up following the fire, which was brought under control by 5.05am.
No one else was hurt in the incident, the fire service said.
They used a high pressure hose reel to tackle the blaze, and contacted residents of the terraced flats to reassure them.
The rubbish was taken out of the building, in the Leith area of the capital.
Three fire engines from McDonald road and Marionville attended the blaze, as well as a fire service cherry picker.
A Lothian and Borders Fire service spokeswoman said: “The fire was started by rubbish set alight
“The rubbish was moved out of the stairwell.”