Patrolling rangers chanced upon the struggling herd in a national park east of Bangkok on Wednesday afternoon, park superintendent Prawatsart Chantheap told AFP.
Once the rangers realised the calves, aged between one and four years old, could not climb out of the dirty watering hole, some left the forest to bring back digging tools while others stayed overnight to keep watch over the frightened creatures.
"Our team arrived with hoes (on Thursday morning)... and we began to dig around the rim (of the mud pit) to make it less steep," he said.
After three hours of digging to build a makeshift ramp, the mud-covered babies managed to stumble out of the pit one-by-one as the rangers cheered them on.
"Go, go, follow each other!" the rangers yelled in a video recorded by the national parks department. "Go, children, go!"
Prawatsart said the rangers had observed a herd of 30 adult elephants nearby and believed the young calves must have been separated from them.
"We believe they were stuck there for at least two days because after they got out their legs were weak," he said.
Wild elephants are Thailand's national animal and live in the wild in parts of the country but their numbers have dwindled to about 2,700 from a peak of over 100,000 in 1850.
Deforestation and habitat loss has brought them in closer contact with humans in recent decades, and they often clash with villagers and farmers.
Elephants are also poached or domesticated for entertainment and tourism.