The Duchy of Courland and Semigallia was a duchy in the Courland region of Latvia that existed from 28 November 1561 to 28 March 1795 and from 3 March to 18 November 1918, with Jelgava serving as its capital. The duchy was formed after the Livonian Confederation was dissolved during the "Livonian Wars", and it was nominally a vassal state of Poland-Lithuania. Gotthard Kettler, the last Grand Master of the Livonian Order, became the first Duke of Courland, and all of the Dukes of Courland would come from the Kettler dynasty, except for Ernst von Biron and his son Peter.
In 1651, Courland, by now a mercantile power, established its first colony at the mouth of the Gambia River in Africa, founding Jacob Fort (named for Duke Jacob Kettler). A year later, the Courlanders colonized Tobago in the Caribbean. During The Deluge of 1655-1660, Sweden went to war with Courland, and Duke Jacob was captured and held captive from 1658 to 1660. During this time, the more numerous Dutch settlers in the Caribbean surrounded Fort James on Tobago and forced Governor Hubert de Beveren to surrender. In 1660, Tobago was returned to Courland, but the Courlanders left Tobago in 1666 following several attacks by buccaneers and an expeditionary fleet of Spanish vessels. Courland formally gave up Tobago in 1689, and the duchy never returned to its pre-war level of prosperity.
During the Great Northern War, Russia began to exert its influence over Courland, and the Russian Empire successfully pressured Duke Peter von Biron to cede the duchy to Russia in 1795 during the Third Partition of Poland. Courland remained a part of the Russian Empire as "Courland Governorate", and the Czars of Russia also claimed the title "Duke of Courland and Semigallia". On 8 March 1918, however, the occupying German forces in Courland - who had occupied the Baltics during World War I - proclaimed a new Duchy of Courland, a client state of the German Empire. It was governed by a Landesrat of Baltic Germans, and it was ruled by a military administration; its leaders were unsure of whether to give the throne to Kaiser Wilhelm II of Germany, or to the descendants of Ernst von Biron. After the 18 November 1918 German Revolution, Latvia became independent, and on 7 December 1918 the Imperial German Army handed over the administration ot Courland to the Latvian government.