The first Saudi to attempt to regain power after the fall of the Emirate of Diriyah in 1818 was Mishari ibn Saud, a brother of the last ruler in Diriyah, Abdullah ibn Saud but he was soon captured by the Egyptians and killed. In 1824, Turki ibn Abdullah ibn Muhammad, a grandson of the first Saudi imam Muhammad ibn Saud who had managed to evade capture by the Egyptians, was able to expel Egyptian forces and their local allies from Riyadh and its environs and is generally regarded as the founder of the second Saudi dynasty as well as being the ancestor of the kings of modern-day Saudi Arabia. He made his capital in Riyadh and was able to enlist the services of many relatives who had escaped captivity in Egypt, including his son Faisal ibn Turki Al Saud. Turki was assassinated in 1834 by Mishari ibn Abdul-Rahman, a distant cousin. Mishari was soon besieged in Riyadh and later executed by Faisal, who went on to become the most prominent ruler of the Saudis' second reign. Faisal, however, faced a re-invasion of Najd by the Egyptians four years later. The local population was unwilling to resist, and Faisal was defeated and taken to Egypt as a prisoner for the second time in 1838. The Egyptians installed Khalid ibn Saud, last surviving brother of Abdullah ibn Saud ibn Abdul-Aziz a great grandson of Muhammad bin Saud, had spent many years in the Egyptian court, as ruler in Riyadh and supported him with Egyptian troops. In 1840, however, external conflicts forced the Egyptians to withdraw all their presence in the Arabian Peninsula, leaving Khalid with little support. Seen by most locals as nothing more than an Egyptian governor, Khalid was toppled soon afterwards by Abdullah ibn Thunayan, of the collateral Al Thunayan branch. Faisal, however, had been released that year and, aided by the Al Rashid rulers of Ha'il, was able to retake Riyadh and resume his rule, later appointing his son Abdallah ibn Faisal ibn Turki as heir apparent, and divided his dominions between his three sons Abdullah, Saud ibn Faisal ibn Turki, and Muhammad. Upon Faisal's death in 1865, Abdullah assumed rule in Riyadh but was soon challenged by his brother, Saud. The two brothers fought a long civil war, in which they traded rule in Riyadh several times. A vassal of the Saudis, Muhammad ibn Abdallah ibn Rashid of Ha'il took the opportunity to intervene in the conflict and increase his own power. Gradually, Ibn Rashid extended his authority over most of Najd, including the Saudi capital, Riyadh. Ibn Rashid finally expelled the last Saudi leader, Abdul-Rahman ibn Faisal, from Najd after the Battle of Mulayda in 1891.