 In 1809 he visited Chile, and having married Mercedes Trucíos y Larraín, an heiress there, took up his residence in that country and joined with enthusiasm the movement for independence in 1810.He had charge of important public offices during the struggle for liberty, including the command of the National guard and the civil and military government of the province of Santiago, and from March 7 to 14, 1814, he was temporarily in charge of the supreme direction of the nation.In 1818 he was appointed Minister of Government and Foreign Affairs by Bernardo O'Higgins, and in October of the same year he went to Buenos Aires as minister.