In 1664 he returned to Spain to assume command of the war against Portugal, which was going poorly after a series of military setbacks, most recently after the defeat in 1663 in the Battle of Ameixial, near Estremoz of the same John of Austria the Younger. Caracena's command of the Spanish forces in Portugal was brief; he was decisively defeated by António Luís de Meneses at the Battle of Montes Claros in 1665. The defeat effectively ended the War of Restoration in favor of the Portuguese.