The rescued migrants said there had been a total of 51 people on board the boat and that many had fallen into the sea when it ran into high waves on Thursday, a spokeswoman for the coastguard said. According to their testimony 22 people are missing.
A pregnant woman and a minor who were among the migrants who were rescued from the boat were evacuated by helicopter to a hospital in the Spanish port of Alicante suffering from hypothermia, she added.
The boat was found 23 nautical miles southeast of Almeria. Three Spanish ships backed by two helicopters were searching the area for signs of the missing migrants.
The coast guard initially reported that it had rescued 28 migrants but revised the number upwards after carrying out a recount.
Thousands of migrants fleeing war and hardship try to cross the 15-kilometre (nine-mile) Strait of Gibraltar from Morocco to Spain on makeshift boats and inflatable dinghies each year.
Thousands also try to reach Spain by scaling border fences that surround Ceuta and Melilla, two Spanish territories inside Morocco which are the European Union's only land borders with Africa.