The Spanish coast guard said another 17 people had been rescued off the coast of Alhucemas.
One survivor said the boat had been carrying more than 70 migrants and a search is continuing, officials said.
Those on the boat are believed to be from sub-Saharan Africa.
A Spanish coast guard plane spotted the boat about 18 miles (29km) off the Moroccan coast on Thursday afternoon following a tip-off nearly 24 hours earlier that it had left Nador, Morocco, and was heading to Spain.
The Spanish newspaper El Pais said the alarm had been raised by a family member of a passenger on the boat.
The aircraft dropped an inflatable raft and some survivors managed to scramble on to it, the paper reported.
The survivors – 14 men and three women – were taken to the Moroccan port of Alhucemas. Some were said to be in need of urgent medical attention.
The BBC’s Tom Burridge in Madrid says hundreds attempt the treacherous crossing from Morroco to Spain every year, often in basic boats, but many don’t survive the journey.
In recent years Spain has seen a decline in the numbers of African migrants reaching its shores by boat, since a peak of 13,425 in 2008.
The migrants, fleeing poverty in West Africa, risk their lives in open, rickety boats threatened by strong currents.