Sir Oliver Tressilian lives at the estate of Penarrow with his brother, Lionel. Oliver is betrothed to Rosamund Godolphin, whose hot-headed brother, Peter, detests the Tressilians due to an old feud between their fathers. Peter and Rosamund's guardian, Sir John Killigrew, also has little love for the Tressilians.
Peter's manipulations drive Oliver into a duel with Sir John. The scheme backfires: Sir John is seriously wounded, further stoking Peter's hatred. Peter attempts to bait Oliver into a violent confrontation, but Oliver is mindful of Rosamund's warning never to meet her brother in an affair of honor. One evening, Lionel returns home, bloodied and exhausted. He has killed Peter in a duel, but there were no witnesses. Oliver is widely believed to be Peter's killer, and Lionel does nothing to disprove the accusations. To avoid repercussions for Peter's death, Lionel has Oliver kidnapped and sold into slavery to ensure that he never reveals the truth. En route to the New World, the slave ship is boarded by the Spanish, and her crew are added to the slaves.
For six months Oliver toils at the oars of a Spanish galley. He befriends a Moorish slave, Yusuf-ben-Moktar. Oliver, Yusuf and the other slaves are freed when the galley is boarded by Muslim corsairs. They offer to fight for the Muslims. Oliver's fighting skills and the testimony of Yusuf, the nephew of the Basha of Algiers, grants Oliver special privileges in Muslim society. He becomes the corsair known as Sakr-el-Bahr, "the Hawk of the Sea". In this new role, Oliver rescues English slaves by purchasing them himself and releasing them in Italy.
Oliver captures a Spanish vessel and discovers his one-time kidnapper, Jasper Leigh, as a slave at the oars. He gives Jasper the opportunity to convert to Islam and join his corsairs. With Jasper's navigational skills, Sakr-el-Bahr sets sail for England to take revenge on Lionel.
Lionel has taken possession of Penarrow. He is now betrothed to Rosamund, who believes that Oliver murdered her brother. Sakr-el-Bahr carries them off to Algiers to be sold as slaves. The Basha takes a fancy to Rosamund, and plans to buy her himself. The Basha does not have enough ready cash to meet the high bid, and Sakr-el-Bahr wins her instead. The Basha threatens to take her by force, but Sakr-el-Bahr marries her, foiling the Basha's efforts. He also buys Lionel and tricks him into revealing the truth about Peter's death.

Question: How are Yusuf and Oliver freed from the slave ship?
Answer: When the Spanish galley is boarded by Muslim corsairs, Yusuf and Oliver offer to fight for the Muslims.
Alternative answer: The galley is boarded by Muslim corsairs