Video shared with Reuters showed the villagers showing the stranded elephants where they've dug the escape route, before they attempted to climb on the steep slope on the side of the pit.
Eventually they all make it out - the last one appearing to turn briefly towards where villagers are cheering before heading off with its companions.
The villagers in the western Rakhine State usually avoid elephants when they come across them in the forest, but they feared the animals would have died if they had stayed trapped in the hole.
"We rescued them because we know that elephants are at risk of vanishing worldwide and they are part of our state's heritage," Zaw Phyo Than, 40, told Reuters by phone.
It was unclear how they fell into the pit.