Consular relations between Russia and what became the modern state of Brazil date back to the early nineteenth century. With the French invasion of Portugal in 1807 during the Napoleonic Wars, the Portuguese Court was transferred to its colony in Brazil. The new capital of the Portuguese Empire was thereafter in Rio de Janeiro. In early July 1811 Friedrich von der Pahlen was appointed envoy to the Portuguese court in Rio de Janeiro. On 30 July that year Xavier and Mikhail Labensky were appointed Consul General and Vice Consul respectively in Rio de Janeiro. Rio de Janeiro ceased to be the capital of the Portuguese Empire in April 1821, with the return of the court to Portugal. The Russian mission moved to Portugal with the court, though consular relations were maintained between Russia and Brazil until November 1827. One of the early consuls during this period was Grigori Langsdorf, who carried out expeditions to the interior of Brazil, gathering material on the flora and fauna, as well as conducting cartographic studies.