The pair were saved following “a call from Morocco to the Spanish sea rescue centre warning that two minors were floating on a lorry tyre in the Bay of Algeciras”, a coastguard spokesman said.
“We mobilised a rescue vessel and warned all the boats in the area. A ferry called us to say that they had spotted them,” he added.
The migrants, whose age or nationality were not known, were taken to the Port of Algeciras.
Increasing numbers of Moroccans and sub-Saharan migrants have been seeking to enter Spain, either by sea or by smuggling themselves into the Spanish enclaves of Ceuta and Melilla, which are in Morocco and the only European territories in Africa.
The International Organization for Migration says that some 51,000 migrants have arrived in Spain by sea this year, and that over 743 have died or gone missing trying.