Lisbon
Lisbon is one of the oldest cities in the world, and one of the oldest in Western Europe, predating other modern European capitals such as London, Paris, and Rome by centuries. Julius Caesar made it a municipium called "Felicitas Julia", adding to the name "Olissipo". Ruled by a series of Germanic tribes from the 5th century, it was captured by the Moors in the 8th century. In 1147, the Crusaders under Afonso Henriques reconquered the city and since then it has been a major political, economic and cultural centre of Portugal. Unlike most capital cities, Lisbon's status as the capital of Portugal has never been granted or confirmed officially – by statute or in written form. Its position as the capital has formed through constitutional convention, making its position as "de facto" capital a part of the Constitution of Portugal.
Portugal
In 1807, as Napoleon's army closed in on Lisbon, the 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.
As a result of the change in its status and the arrival of the Portuguese royal family, Brazilian administrative, civic, economical, military, educational, and scientific apparatus were expanded and highly modernized. Portuguese and their allied British troops fought against the French Invasion of Portugal and by 1815 the situation in Europe had cooled down sufficiently that João VI would have been able to return safely to Lisbon. However, the King of Portugal remained in Brazil until the Liberal Revolution of 1820, which started in Porto, demanded his return to Lisbon in 1821.