The Battle of Medina in 1812 was part of the First Campaign of the Ottoman–Wahhabi war. Following his defeat at the Battle of Al-Safra, Tusun Pasha's forces regrouped and made another attempt to reach Saud's Wahhabi forces in Medina.

Prelude 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. Since he had only three thousand fighters out of eight thousand regular soldiers with him, he quickly asked for help from his father,Abd al-Rahman al-Rafai, The era of Muhammad Ali, p. 128 reporting that his defeat was due to disputes between his commanders. The loss shocked Muhammad Ali. Still, it didn't prevent him from continuing the campaign.Abd al-Rahman al-Rafai, The era of Muhammad Ali, p. 128

In 1812, Muhammad Ali Pasha prepared another expedition, with an army of 20,000 men, 18 guns, and three mortars,Revolutionary Wars 1775–c.1815 led by Ahmad Bonaparte.Othman bin Bishr, Glory in the History of Najd, p. 328 Both Tusun and Ahmad marched again to Wadi Al-Safra and successfully captured it without a fight. Many of the Arab tribes, such as Juhaynah and Harb tribes supported the Ottomans.Othman bin Bishr, p. 328Abd al-Rahman al-Rafai, p. 129

Battle In October 1812,John Lewis Burckhardt, Notes on the Bedouins and Wahábys, p. 353 Tusun was ready again to march against Medina; his men were to rest at daylight and march at night. His march lasted for three nights until they arrived in Medina.Abd al-Rahman al-Rafai, p. 129 Some skirmish happened between the Saudi garrison and the Ottomans, in which Ahmad Bonaparte successfully drove them into the inner city of Medina. The city was well fortified with high walls.John Lewis Burckhardt, p. 354 the Ottomans prevented from bombarding the city hoping it would not damage Al-Masjid an-Nabawi, Tusun then ordered the inhabitants to stay in their houses to avoid further damage.Abd al-Rahman al-Rafai, p. 129

The Saudi garrison numbered 14,000 men.Genelkurmay Harp Tarihi Başkanlığı. (1978). Türk Silahlı Kuvvetleri Tarihi (1793–1908) (C. 3, Ks. 5, s. 533). T.C. Millî Savunma Bakanlığı. They made several sorties for the next fourteen or fifteen daysJohn Lewis Burckhardt, p. 354 while also suffering from diseases and a lack of water as the Ottomans cut off the water supply.Othman bin Bishr, p. 329 The Ottomans began mining tunnels to blow up the walls. A first attempt by the Ottomans was discovered by the garrison, which stopped the mines. A second attempt was done in November, which successfully destroyed a portion of the walls.John Lewis Burckhardt, p. 354Othman bin Bishr, p. 329Abd al-Rahman al-Rafai, p. 129 The Ottomans charged into the opened gap and successfully fought the Saudi garrison killing 1,000 of them while losing only 50. The remainder of the garrison escaped to a castle nearby, numbering 1,500 men.John Lewis Burckhardt, p. 354Othman bin Bishr, p. 329

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.John Lewis Burckhardt, p. 354 This action disgusted their Arab allies and the garrison leader, Mas'ud Bin Madhian, was taken to Constantinople and executed there.John Lewis Burckhardt, p. 354

Aftermath The capture of Medina was the first major Ottoman-Egyptian victory in the Wahhabi War. Soon, news reached Cairo and celebrations were made for this victory. The Ottoman-Egyptian army then marched to Al Hinakiyah and captured it.Abd al-Rahman al-Rafai, p. 129

References