Emergency responders had battled since Monday to free the workers after the tunnel collapsed in southwestern Yunan province, China's official Xinhua news agency reported.
Rescuers managed to drill a hole through the debris to the stranded crew on Tuesday, passing them food, water and flashlights.
They were finally freed "in the early hours of Sunday", Xinhua reported. One worker who was in the tunnel at the time of the collapse remains unaccounted for.
China's transport infrastructure has developed rapidly in recent years, particularly its high-speed rail network, which was only established in 2007.
The accident caused a torrent of public criticism of the government amid accusations that authorities compromised safety in their rush to expand the network.