The whales were among a group of 26 stranded on the beach between Anstruther and Pittenweem at 7am on Sunday.
Of the creatures that died, three are said to have been young calves.
The whales, which can grow up to 20 feet in length, became stranded when they were trapped in the cove at low tide.
Teams from the Fife Coastguard and British Divers Marine Life Rescue, along with police and local vets, battled for hours to save the mammals.
Another group of pilot whales, believed to be the rest of a larger pod, congregated in shallow water about three miles away at Cellardyke.
A spokesman for British Divers Marine Life Rescue said: "It may well be that the animals came closer to land in an attempt to catch food.
"We don't, however, know what is going on out at sea. There may be something natural or man-made that is causing them to come in closer."
Whales that become stranded out of the water die as gravity affects their heavy bodies.
The spokesman added: "The main thing we need to do is get them upright. If they get stuck on their sides they can have a pooling of blood that causes the lungs to shut down. Getting them upright allows the blood to re-circulate.
"We also need to make sure they are kept wet and cool. If they are not, then they can overheat very quickly.
"They have a thick layer of blubber, which is great for when they are in the sea but once they come on land it can cause them to overheat and become dehydrated."
Vets tended to the animals at the scene in attempt to monitor and stabilise them.
Officers from Fife Police were also called to ensure members of the public did not try to get involved in the rescue operation.
David Galloway, a fish filleter from Anstruther, watched the events unfold.
He said: "I went down to the beach at about 12pm and I could see all the whales. It was horrible – I have never seen anything like it in my life.
"We were told we couldn't go down onto the beach but we could see rescuers beside the whales. They were trying to take care of them, trying to keep them moist."
When the tide came in at 4.30pm, 10 whales were able to refloat and head to sea.
But the rescuers' excitement was short-lived, as two of the animals made their way back to the land and re-stranded themselves.
Last night they were being monitored, while the other refloated animals appeared to be waiting for them at the entrance to the cove.
The pilot-whale stranding is the largest in the UK since a group of 77 animals were stranded at Kyle of Durness, in the north of Scotland, in July last year.
In that incident 33 animals died despite rescue attempts.