In 1807, as Napoleon's army closed in on Lisbon, João VI of Portugal, the Prince Regent, transferred his court to Brazil and established Rio de Janeiro as the capital of the Portuguese Empire. In 1815, Brazil was declared a Kingdom and the Kingdom of Portugal was united with it, forming a pluricontinental state, the United Kingdom of Portugal, Brazil and the Algarves.