Derbyshire Cave Rescue Organisation (DCRO) was called out after three cavers failed to return from a trip into Gautries Hole, north of Buxton.
Heavy rain had caused a section of passage close to the entrance to become completely flooded, leaving the cavers with no way out.
They were rescued by the team using underwater breathing apparatus.
Bill Whitehouse, from the DCRO, said: "They were very experienced cavers who knew what had happened and what the consequences were.
"They did exactly the right thing and found somewhere to hold-up until help came."
He added: "Once they were beyond the flooded part of the cave they were quite safe - it's just they couldn't get out."
The team took the decision to "dive them out" because the water level was not going down and more heavy rain was forecast, meaning they could have remained trapped for a long period.
Mr Whitehouse said it was unusual for the cave to be totally flooded.
A rescue team has used divers for the first time in 20 years to free people trapped inside a flooded cave.