After the disgrace of Philippe II, Duke of Orléans, under whom he served and who plotted to replace Philip V, he switched to the Habsburg cause of Charles VI, keeping his rank.
At the beginning of the War of Spanish Succession, he fought with the army of Philip V, but the fall from grace of the Duke of Orléans forced him to Galicia where he joined the Allied anti-Borbón league.
[2] In recognition of his accomplishments, he was appointed supreme commander of the forces of Catalonia and was charged with organizing city defenses in the 1713-14 Siege of Barcelona.
He spent his last years confined in a cell that flooded with the rising tide, a circumstance that caused a total paralysis of his two legs.
Until then, it was considered that Villarroel had been released from the Alcazar of Segovia following the peace of Vienna and had lived in the pension that would have granted, until his death, the Archduke Charles Emperor of the Holy Roman Empire.