A maritime rescue service ship made contact with the boat off the coast of the province of Cadiz and took the would-be immigrants to the port of Tarifa, he said.
The 32 passengers of the fishing boat, including the woman and her child, appeared to be in good health, the spokesman added.
The maritime rescue service was alerted to the presence of the boat after one of the migrants called Spanish emergency services to ask for help because the vessel's motor had stopped working.
Thousands of people from Africa regularly attempt to cross from Morocco into Spain on makeshift boats each year.
Authorities fear many of those who attempt the crossing by sea die of thirst, hunger or exposure.