His reign was ill-fated and was to end abruptly. In 1805, he joined the Third Coalition against Napoleon. His campaign went poorly and the French occupied Swedish Pomerania. When his ally, Russia, made peace and concluded an alliance with France at Tilsit in 1807, Sweden and Portugal were left as Great Britain's European allies. On 21 February 1808, Russia invaded Finland, which was ruled by Sweden, on the pretext of compelling Sweden to join Napoleon's Continental System. Denmark likewise declared war on Sweden. In just a few months after, almost all of Finland was lost to Russia. As a result of the war, on 17 September 1809, in the Treaty of Hamina, Sweden surrendered the eastern third of Sweden to Russia. The autonomous Grand Principality of Finland within Imperial Russia was established.