Residents of a property on Elcho Street, Peebles, were woken by the crackling of the blaze at 3am.
And the occupants, including a three-year-old girl, were rushed to Borders General Hospital suffering from smoke inhalation.
They have since been released.
Firefighters have confirmed there was no working smoke alarm in the Peebles flat.
The blaze ravaged the home and smoke damaged the surrounding properties.
Neighbours were evacuated from their homes during the incident.
A spokeswoman for Lothian and Borders Fire and Rescue Service said: "Early indications suggest the fire broke out as a result of a candle left burning in the property.
"This is something that we have seen before and we cannot stress enough if you use candles that you must make sure they are fully extinguished before going to bed.
"There was no smoke detection in the flat either and so it is fair to say the family had a very lucky escape.
"When fire breaks out, particularly in the early hours of the morning, it can be very disorientating and the risks of being overcome by smoke are significant."
And she told the Peeblesshire News how the fire brigade are adamant that every home should have a working smoke detector.
She added: "We are very relieved that the family in question managed to escape although they did suffer smoke inhalation.
"We wish them a speedy recovery and would take this opportunity to remind people of the need for vigilance when it comes to fire safety.
"Get into the habit of making checks in your home before you go to bed or leave your home for the day.
"In addition, make sure you have a working smoke alarm in your house. It really could save your life one day."
If you live in the Lothian and Borders area you arrange a free home safety visit and fitting of smoke detectors as required by calling 0800 169 0320.