Ferdinand IV was restored as king; however, after only seven years Napoleon conquered the kingdom and installed Bonapartist kings, including his brother Joseph Bonaparte (the Spanish king). With the help of the Austrian Empire and its allies, the Bonapartists were defeated in the Neapolitan War, and Ferdinand IV once again regained the throne and the kingdom.