At the outbreak of the war he was appointed chief of the General Staff of the army, carrying out a remarkable job of training the first Chilean infantry that were sent to Peru.[3] On June 26, 1879 he was appointed Inspector General of the Army and National Guards and on October 18 of the same year he was appointed Commander-in-Chief of the Reserve Army. As such, he was left in charge of the nitrate fields expropriated by Peru, openly proposed their nationalization and opposed their handing over to private parties.[4]: 201
On August 29, 1880, he was promoted to Division General. After the departure of Erasmo Escala, there were proposals to appoint Villagrán as Commander in Chief but finally the government appointed Manuel Baquedano in office and Villagrán was appointed chief of the first division of the Army, which, according to the plan, was to march 8 days from Pisco to Lurín in a dry and inhospitable region to clear the backs of the divisions that would land in the Lurín River. Villagrán, in view of the enormous difficulties and the lack of supplies, warned Baquedano that it would not be his responsibility if the march failed. Baquedano answered that the responsibility always belongs to whoever gives the order and asked the government for Villagrán's removal, which the government did. Shortly after, he was appointed Member of the Services Qualifying Commission.
He died at the age of 74 on June 17, 1895.[1][2]