Riley stayed back to distract the Arabs and give his men a chance to escape in the loaded and unfinished boat.
With their agreement, crew member Antonio Michele swam to shore to pay them, at which point Riley ran out into the water to join his men.
As the ship, still aground, was unusable, unable to reach what are now the islands of Cape Verde, the crew decided to sail to the South while hoping for rescue, which did not come.
After nine days, out of food and water, they returned to the shore at an isolated beach 200 miles (320 km) further south, with the realization that they would probably be killed just as quickly as Michele.
Out of food and water, Riley resolved that they should either accept death or offer themselves as slaves to the first tribe they encountered, which is exactly what happened.
Riley asked two of them, Sidi Hamet and his brother, if they would buy him and his fellow shipmates and bring them to the closest city - which was Mogador (now Essaouira) - hundreds of miles away to the north.
Amazingly, they traveled the distance to the city - several hundred miles, constantly in fear of marauding hunter tribes.
Hamet met a young man in the city, who, it turns out, worked as an assistant to a British merchant who also acted as a kind of consul and agent.
Two of the missing men were later returned to the States, and Riley heard of two Arabs who were stoned to death out in the desert by marauders.
Abraham Lincoln, who later became president of the United States, listed Sufferings in Africa, as one of the three most influential works that shaped his political ideology, particularly his views on slavery.
James Riley, from the Period of His Return to His Native Land, After His Shipwreck, Captivity and Sufferings Among the Arabs of the Desert, as Related in His Narrative, Until His Death.