The man's older brother appears to have tried to smuggle him into Spain by ferry.
The older man, aged 34, legally boarded the ferry linking Melilla, a tiny Spanish territory in north Africa, and Almeria in southern Spain with a car on yesterday, a police spokesman said.
During the crossing he noticed that his brother was not breathing and alerted the ferry's staff.
Crew members as well as emergency services workers in the port of Almeria tried in vain to resuscitate the man.
More From This Section
In May police discovered an 8-year-old boy from the Ivory Coast curled up inside a suitcase -without air vents- that was being carried across a pedestrian crossing from Morocco into Ceuta, Spain's other north African territory.
A security scanner picture of the boy curled up in the suitcase served as a shocking reminder of the lengths migrants take to try to seek a better life in Europe.
His father, a legal resident in Spain, had tried to smuggle the boy into Spain because his income was too low to request residency papers for his son.
Each year, thousands of migrants risk their lives trying to enter Ceuta and Melilla, which have the European Union's only land borders with Africa, to try to enter Europe.
Many migrants try to scramble over the seven-metre fences that separate the Spanish cities from Morocco while others try to swim or sail from shores on the Moroccan side.
Four migrants died on yesterday after trying to swim around a maritime fence separating Ceuta from Morocco, the Moroccan authorities said.