After his participation in the War of Morocco, he got the rank of general. He accompanied King Alfonso XII, who was in France at that moment, in his return to occupy the throne. In 1896, the Queen asked him to take charge of the education of the prince Alfonso XIII. In 1902, Alfonso XIII came of age and nominated him as his private secretary.
He published his poems in 1870 and a second edition in 1903. He also published La defensa de la sociedad and other works in the magazine ‘Revista de Marina’ and left unpublished a verse comedy titled Naufragar en la orilla.
He was conferred the title ‘Count of Andino’.