Finland was a Swedish province from the 12th century but despite this its ownership was contested by the Russians. During the wars of Charles XII parts of Finland were lost to the Russians and in 1788 the Swedes under Gustavus II attempted to recapture what they had lost. During the Russo-Sweddish war of 1808 Sweden finally lost control of Finland under the conditions of the Treaty of Fredrikshavn. Finland became a semi-independant grand Duchy under Russian rule with the Tsar as grand Duke, retaining her own constitution, laws and senate. The province of Viborg which had been lost to the Russians in the early 18th century was returned to Finland in 1811. Until 1809 the Finnish forces were regiments within the Swedish army such as the 3rd Guard regiment but these were disbanded under Russian rule. Finnish Dragoon regiments in Russian service had red facing and yellow buttons.