After the defeat at the hands of the Saudis in the Battle of Al-Safra, Tusun Pasha fled with his surviving force, heading towards Yanbu, and fortified himself there.
[2] In 1812, Muhammad Ali Pasha prepared another expedition, with an army of 20,000 men, 18 guns, and three mortars,[3] led by Ahmad Bonaparte.
[8] Some skirmish happened between the Saudi garrison and the Ottomans, in which Ahmad Bonaparte successfully drove them into the inner city of Medina.
[17][18] The Ottomans, not having proper artillery and the castle being mining proof, besieged them for three weeks until the Saudis, lacking supplies, surrendered with a promise of granting safe and unmolested passage, however, once they had gotten out of the castle, Ahmad Bonaparte broke his promise and attacked them, killing many of them and a few of them escaped.
[19] This action disgusted their Arab allies and the garrison leader, Mas'ud Bin Madhian, was taken to Constantinople and executed there.