Answer
Philip V was the great-nephew of Charles II of Spain, who named him as his heir presumptive in his will. Charles II had no surviving children, and his death in 1700 triggered the War of the Spanish Succession, a conflict between France and the Grand Alliance (which included Great Britain, the Dutch Republic, and the Holy Roman Empire) over who would inherit the Spanish throne.