Ottoman Sultan Mahmud II sent in troops ostensibly to restore order, marking the end of both the Karamanli dynasty and an independent Tripolitania. Order was not recovered easily, and the revolt of the Libyan under Abd-El-Gelil and Gûma ben Khalifa lasted until the death of the latter in 1858. The second period of direct Ottoman rule saw administrative changes, and greater order in the governance of the three provinces of Libya. Ottoman rule finally reasserted to Fezzan between 1850 and 1875 for earning income from Saharan commerce.