They were the latest of hundreds of migrants to die trying to reach Europe from African shores over recent years.
A humanitarian organisation alerted the Spanish coastguard that the dinghy had set sail from Morocco early on Wednesday with eight people in it, a coastguard official told news agency AFP.
A rescue boat set out from Ceuta, a Spanish territory on the north coast of Morocco, in rough weather with waves two metres (more than six feet) high to search for the boat.
"The dinghy apparently ran into problems," the official said.
"About 5:30 pm (1530 GMT) the rescue boat recovered from the water the corpse of a man of sub-Saharan origin who was wearing a life jacket. About 20 minutes later the boat found a second corpse."
The coastguard then called off the search for the day and the rescue boat returned to Ceuta pending a decision on whether to resume the search on Thursday, said the official, who asked not to be named.
Thousands of migrants fleeing war and hardship try to cross the 15-kilometre (nine-mile) strait from Morocco to Spain on makeshift boats and inflatable dinghies each year.
Thousands also try to reach Spain by scaling the border fences that surround Ceuta and Melilla, two Spanish territories bordering Morocco which have the European Union's only land borders with Africa.
Elsewhere in the Mediterranean, hundreds of migrants have drowned trying to reach Italy by sea from north Africa and the Italian navy says it has rescued tens of thousands more from boats.