The Grand Duchy of Baden was a state in the southwest of Germany, on the east bank of the Rhine. It existed between 1806 and 1918. It came into existence in the 12th century as the Margraviate of Baden and subsequently split into different lines, which were unified in 1771. It became the much-enlarged Grand Duchy of Baden through the dissolution of the Holy Roman Empire in 1803–06 and was a sovereign country until it joined the German Empire in 1871, remaining a Grand Duchy until 1918 when it became part of the Weimar Republic as the Republic of Baden. Baden was bordered to the north by the Kingdom of Bavaria and the Grand Duchy of Hessen-Darmstadt; to the west and practically throughout its whole length by the River Rhine, which separated it from the Bavarian Rhenish Palatinate and Alsace in modern France; to the south by Switzerland, and to the east by the Kingdom of Württemberg, the Principality of Hohenzollern-Sigmaringen and partly by Bavaria.