More than 100 whales swam ashore in the Yoff neighbourhood of Senegal's capital, Dakar, on Wednesday.
A spokeswoman for the charity WWF said more than 30 of the whales were killed.
Local residents who rushed to the beach to see the whales used boats to drag others back out to sea.
Whales often become stranded at this time of year in countries such as Cape Verde and Mauritania.
But a WWF spokeswoman said it had been some 20 years since a similar incident in Senegal.
Efforts are under way to bury the carcasses and an investigation has begun to see what caused the whales to swim ashore.