The European country had been under Brazilian rule when both were part of the United Kingdom of Portugal, Brazil and the Algarves, established by King João VI during his stay in Rio de Janeiro from 1808 until 1820.