During the War of the Spanish Succession, Joseph Ferdinand was the favored choice of England and the Netherlands to succeed as the ruler of Spain, as the heir, young Charles II of Spain was incompetent. He was the electoral prince of Bavaria, and a great-grandson of Philip IV. His unexpected death in 1699 at the age of six rendered the Anglo-French treaty inoperative and led to the Second Partition Treaty (1700), agreed upon by France, England, and the Netherlands; under its terms, France was to receive Naples, Sicily, and Milan, while the rest of the Spanish dominions were to go to Archduke Charles.