During the Finnish War between Sweden and Russia, the four estates of occupied Finland were assembled at the Diet of Porvoo on 29 March 1809 to pledge allegiance to Emperor Alexander I of Russia, who had already earlier during the war adopted the title Grand Duke of Finland to his long litany of titles. Following the Swedish defeat in the war and the signing of the Treaty of Fredrikshamn on 17 September 1809, Finland became in some aspects an autonomous Grand Duchy, as in an informal real union with the Russian Empire.