Philip V of Spain had the longest reign in modern Spanish history at 45 years and 21 days.
Philip V of Spain . The sum of his two reigns , 45 years and 21 days , is the longest in modern Spanish history .