and had to quell revolts many times: 1824–1825, 1828, 1831–1832, 1843, 1849, 1852, 1853, and 1857–1858. He was always successful at placating the nobles and malcontents though. Conflict with the French Invasion of Algiers (1830) The most serious foreign threat to Morocco, however, was France, which had launched its invasion of neighboring Ottoman Algeria in 1830. The French landing at Sidi Feruj near Algiers and subsequent French victory in the battle of Staouéli caused panic in Morocco, while Moroccans expressed solidarity with the Algerians. In the summer of 1830, Abd al-Rahman accepted boatloads of Algerian refugees arriving in the ports of Tangier and Tetuan, ordering his governors to find them housing and settle them into work. Occupation of Tlemcen (1830–1831) After consulting the ulama of Fes, Abd al-Rahman sent Moroccan troops to defend Tlemcen in 1830, consisting of 5,000 cavalry and two pieces of artillery from Fes, under the son of the sultan, Ali. The troops established their headquarters at Tlemcen, in the province of Oran. The Moroccan troops were warmly welcomed, even in the provinces of Tittery and Constantine, however upon discovering that Turkish and Kouloughli remnants were still fighting among themselves, angered by the stalemate, undisciplined Moroccan soldiers rampaged through the streets of Tlemcen in March 1831, leading to the sultan ordering them to withdraw from the city. Another embassy was sent to Fes, Abd al-Rahman complied with their request and sent an agent to Mascara, the agent was eventually withdrawn. Tlemcen was captured by the French in 1836 after the Battle of Mascara in 1835. Support for Emir Abd al-Qadir (1832–1844) Abd al-Rahman supported the continued guerrilla resistance in Algeria led by Abd al-Qadir al-Jaza'iri who was in theory, a vassal of the Moroccan sultan, albeit only tentatively, not wishing to incur French retaliation. But the border tribes of Morocco continued supporting Abd al-Qadir more actively, prompting the French launch their own strikes over the border and establishing forward outposts in Moroccan territory, which only inflamed the reaction in Morocco and increased the irregular border war. The Moroccan army attacked a French military group which France considered a declaration of war. After learning that the Sultan had sent huge forces to the eastern front, Peugeot gave Morocco a deadline of eight days to withdraw its armies from the east, but the Sultan was not convinced. Franco-Moroccan War (1844) The French then demanded that Morocco cease its support