Spain's maritime service said rescuers had picked up 12 migrants who were travelling on two boats while Morocco had intercepted 11 people who were on another two vessels.
The migrants were given blankets and transported to the port of Tarifa in the Spanish province of Cadiz which is located across the Strait of Gibraltar facing Morocco.
Spanish police then took them to a detention centre for undocumented migrants.
The use of inflatable rubber boats, instead of larger and more secure wooden fishing vessels, by African migrants trying to enter Spain from Morocco is on the rise.
Spanish authorities on Monday intercepted 27 illegal immigrants travelling in three inflatable boats. Another 35 migrants were picked up on March 18 on
four inflatable boats.
"The 'modus operandi' used by migrants trying to reach Spain has changed in recent months," said Antonio Fernandez, the head of emergency operations for the Spanish Red Cross.
"Instead of using a boat where 30 or 40 people attempt the crossing, they are literally buying toy boats made of plastic with room for four, five or six people and they try to cross," he said.
"This method is more precarious, if that is possible. There is a greater risk of sinking and therefore of drowning."
The Strait of Gibraltar separates Spain and Morocco by only 15 kilometres (nine miles) — a ferry ride between the two continents takes roughly 35 minutes — making it one of the key smuggling routes for illegal immigrants crossing into Europe.
Thousands of illegal migrants from Africa regularly attempt to cross from Morocco into Spain on makeshift boats each year.
Some travel thousands of miles overland, being handed from smuggler to smuggler, ending up at one of many ports in northern Africa for a cramped and treacherous sea crossing to European soil.
The number of migrants who arrived on Spanish shores by boat last year totalled 3,804, a 30 percent drop from 2012, according to interior ministry figures.
Other migrants try to cross illegally into the tiny Spanish enclaves of Ceuta and Melilla, perched on the coast of north Africa and both claimed by Morocco.
Spain reinforced the metal border fence separating Melilla from Morocco in August after a resurgence of crossing attempts, with hundreds of would-be immigrants waiting nearby for a chance to climb over.
Earlier this month about 150 African migrants stormed a border fence in Melilla and crossed illegally from Morocco into Spanish territory and about 50 of them managed to enter the enclave.
Twelve people were injured, including two Spanish policemen who were attacked as they tried to stop the migrants, according to the local Spanish government delegation.
The Moroccan Association of Human Rights said 25 people were injured, including a 30-year-old from Cameron who died from his injuries on March 18 at a hospital in the Moroccan city of Nador.
Medical aid group Doctors Without Borders announced on March 13 that it was closing its projects in Morocco in protest at the plight of African migrants allegedly abused by Spanish and Moroccan police as they try to reach European soil.
Melilla received 2,224 illegal immigrants last year, 262 more than in 2011, according to Spanish Interior Minister Jorge Fernandez Diaz.
Instability in Africa's Sahel region, especially in Mali, is behind the rise in illegal immigrants trying to enter the enclave, he added.