The boys, aged nine and ten, got into difficulty on a building site near the Jack Kane Centre.
A man in a nearby flat managed to rescue one of the boys but became stuck in the mud himself while trying to release the other youngster.
A spokeswoman for Lothian and Borders Fire and Rescue Service said: “One child had been with the boys but did not get stuck in the mud and went home to tell his mum, who called the fire service.
“A male adult in nearby flats heard the children calling out and went to their aid. He managed to release one of the boys but got stuck releasing the second.”
Firefighters were called to the scene just after 7pm yesterday, with crews from Newcraighall, Marionville, Tollcross and Liberton attending, using a nine-metre ladder to rescue them.
The adult refused treatment, while the children were taken to the Edinburgh Sick Kids hospital as a precaution.