The disagreements between Maroto and Olañeta culminated in 1824, when Olañeta, who had proposed to reestablish the absolutist regime in Peru, as it had now been established in Spain, marched with his troops against him, obligating them to abandon their positions. Despite the viceroy's intentions in favor of dialogue, the matter degenerated into a civil war that weakened the royalist troops and permitted the loss of Peru. Maroto was next named by La Serna as chief of one of the three divisions that, under the orders of General José de Canterac had to face the invasion by Antonio José de Sucre. After the Battle of Junín, Maroto maintained strong disagreements with Canterac and ended up resigning, since he considered that the withdrawal of the Royalist forces was being carried out in an inadequate way. Named governor of Puno, he was there taken by surprise by the capitulation of Ayacucho, in which Puno was included. Accompanied by La Serna and others officials, Maroto and his family embarked on the French frigate "Hernestine", which arrived in Burdeos in the middle of 1825.