Related to General Serrano, he participated with him in the Revolution of 1868 and the Battle of Alcolea, in which the loyalists under Manuel Pavía were defeated.
In 1871, he became mariscal de campo and personal military advisor to King Amadeo I of Spain.
During the Second Melillan campaign, he became captain-general and was also the representative of Malaga in the Spanish senate, a chamber of which he became the president between 1905 and 1907.
In July 1906, aged 77, he became prime minister of Spain with a government supported by José Canalejas.
After his resignation, he retired from politics In 1908, he was given the Toison de Oro, or Order of the Golden Fleece.